www.digitalmars.com         C & C++   DMDScript  

D - private ??

reply eriser <eriser_member pathlink.com> writes:
class	pouet
{
private:

this()
{
a = 3;
}

void	test()
{
printf("private !!!");
}

int	a;
}

void main()
{
pouet p = new pouet();
p.test();

printf("%d", p.a);
}
Mar 29 2004
next sibling parent eriser <eriser_member pathlink.com> writes:
return:

C:\bin\code\D\dmd\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;

D:\eriser\D>test.exe
private !!!3
Mar 29 2004
prev sibling next sibling parent e <e_member pathlink.com> writes:
result !

D:\eriser\D>dmd test.d
C:\bin\code\D\dmd\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;

D:\eriser\D>test.exe
private !!!3
Mar 29 2004
prev sibling next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
eriser wrote:

//Module 1

class	pouet
{
private:

this()
{
a = 3;
}

void	test()
{
printf("private !!!");
}

int	a;
}
  

//Module 2
void main()
{
pouet p = new pouet();
p.test(); //Will be in error

printf("%d", p.a); //Will be in error
}

-- -Anderson: http://badmama.com.au/~anderson/
Mar 29 2004
prev sibling parent Andy Friesen <andy ikagames.com> writes:
eriser wrote:
 class	pouet
 {
 private:
 
 this()
 {
 a = 3;
 }
 
 void	test()
 {
 printf("private !!!");
 }
 
 int	a;
 }
 
 void main()
 {
 pouet p = new pouet();
 p.test();
 
 printf("%d", p.a);
 }

It's because everything is in the same module. D treats them as friends. (to use the C++ term) -- andy
Mar 29 2004