Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 29, 2004 private ?? | ||||
---|---|---|---|---|
| ||||
class pouet { private: this() { a = 3; } void test() { printf("private !!!"); } int a; } void main() { pouet p = new pouet(); p.test(); printf("%d", p.a); } |
March 29, 2004 Re: private ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to eriser | return: C:\bin\code\D\dmd\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; D:\eriser\D>test.exe private !!!3 |
March 29, 2004 Re: private ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to eriser | 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 |
March 29, 2004 Re: private ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to eriser | 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 >} > Visibility rules are on the modular level in D, if that was your question. -- -Anderson: http://badmama.com.au/~anderson/ |
March 29, 2004 Re: private ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to eriser | 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
|
Copyright © 1999-2021 by the D Language Foundation