Thread overview
'private' attribute ignored???
Jun 25, 2005
Mike
Jun 25, 2005
Vathix
Jul 02, 2005
Hasan Aljudy
June 25, 2005
The following compiles without complaint, and I can't for the life of me see why. Maybe a noob error that belongs on the 'learn' NG, but it's surprising to say the least.

This is with both 0.126 and 0.127

------------

class Test
{
private int a;

private { int b; }

private:
int c;
}

void main()
{
Test test = new Test;
test.a = 1;
test.b = 1;
test.c = 1;
}


June 25, 2005
Private is ignored within the same file iirc (because it assumes you know what you're doing if you mess with your own classes.)

-[Unknown]


> The following compiles without complaint, and I can't for the life of me see
> why. Maybe a noob error that belongs on the 'learn' NG, but it's surprising to
> say the least.
> 
> This is with both 0.126 and 0.127
> 
> ------------
> 
> class Test
> {
> private int a;
> 
> private { int b; }
> 
> private:
> int c;
> }
> 
> void main()
> {
> Test test = new Test;
> test.a = 1;
> test.b = 1;
> test.c = 1;
> }
> 
> 
June 25, 2005
On Sat, 25 Jun 2005 13:44:06 -0400, Mike <Mike_member@pathlink.com> wrote:

> The following compiles without complaint, and I can't for the life of me see
> why. Maybe a noob error that belongs on the 'learn' NG, but it's surprising to
> say the least.
>
> This is with both 0.126 and 0.127
>
> ------------
>
> class Test
> {
> private int a;
>
> private { int b; }
>
> private:
> int c;
> }
>
> void main()
> {
> Test test = new Test;
> test.a = 1;
> test.b = 1;
> test.c = 1;
> }
>

Not a bug. You can access private stuff within the same module. It's D's solution to friendship.
July 02, 2005
Mike wrote:
> The following compiles without complaint, and I can't for the life of me see
> why. Maybe a noob error that belongs on the 'learn' NG, but it's surprising to
> say the least.
> 
> This is with both 0.126 and 0.127
> 
> ------------
> 
> class Test
> {
> private int a;
> 
> private { int b; }
> 
> private:
> int c;
> }
> 
> void main()
> {
> Test test = new Test;
> test.a = 1;
> test.b = 1;
> test.c = 1;
> }
> 
> 

Like the others said, private is ignored inside the same file :/ not truely OOP, I made a post to complain about it, but it seems not many people agree with me.
http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/23420