| Thread overview |
|---|
May 18, 2007 private class members | ||||
|---|---|---|---|---|
| ||||
Hi!
Maybe I am wrong, but in normal case this source should not compile, because I can access private class member outside of the class. What is wrong?
Here is the code:
class Bar
{
private int member;
private int member2;
};
int main()
{
Bar bar = new Bar();
bar.member = 10;
bar.member2 = 11;
return 0;
}
| ||||
May 18, 2007 Re: private class members | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Christoph | Reply to Christoph,
> Hi!
>
> Maybe I am wrong, but in normal case this source should not compile,
> because I can access private class member outside of the class.
> What is wrong?
> Here is the code:
>
> class Bar
> {
> private int member;
> private int member2;
> };
> int main()
> {
> Bar bar = new Bar();
> bar.member = 10;
> bar.member2 = 11;
> return 0;
> }
it's all in the same module. In D everything in a single module has "friend" access to everything else in the module.
| |||
May 18, 2007 Re: private class members | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS Wrote:
> Reply to Christoph,
>
> > Hi!
> >
> > Maybe I am wrong, but in normal case this source should not compile,
> > because I can access private class member outside of the class.
> > What is wrong?
> > Here is the code:
> >
> > class Bar
> > {
> > private int member;
> > private int member2;
> > };
> > int main()
> > {
> > Bar bar = new Bar();
> > bar.member = 10;
> > bar.member2 = 11;
> > return 0;
> > }
>
> it's all in the same module. In D everything in a single module has "friend" access to everything else in the module.
>
>
Ah I see, now its clear.
thank you
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply