www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - 'private' attribute ignored???

reply Mike <Mike_member pathlink.com> writes:
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;
}
Jun 25 2005
next sibling parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
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;
 }
 
 
Jun 25 2005
prev sibling next sibling parent Vathix <chris dprogramming.com> writes:
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.
Jun 25 2005
prev sibling parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
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
Jul 02 2005