struct encapsulation
alex
alexibu.nospamplease at mac.com
Mon Feb 19 18:22:17 PST 2007
alex Wrote:
> This code compiles - I don't think it should.
> If b is a private member of A then why can I change it outside the class ?
>
> struct A
> {
> private:
> int b;
> };
>
>
> int main()
> {
> A a;
> a.b = 10;
>
> return 0;
> }
The code compiles when the accessing code is in the same module, otherwise it fails as expected.
Sorry I misunderstood the meaning of private.
Alex
More information about the Digitalmars-d
mailing list