www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - template class inheritance - bug with private

reply Sark7 <sark7 mail333.com> writes:
class A
{
	this() {}
}

class B(): A
{
private: // if I remove this line, module compiles successfully
	int foo;
}

class C: B!()
{
	this() { printf("C "); }
}

void main()
{
	C c = new C();
}

Compiler [dmd v0.94] outputs: class C member this is not accessible
Jul 06 2004
parent J C Calvarese <jcc7 cox.net> writes:
Sark7 wrote:
 class A
 {
     this() {}
 }
 
 class B(): A
 {
 private: // if I remove this line, module compiles successfully
     int foo;
 }
 
 class C: B!()
 {
     this() { printf("C "); }
 }
 
 void main()
 {
     C c = new C();
 }
 
 Compiler [dmd v0.94] outputs: class C member this is not accessible

I agree it's a bug (and it's still there in DMD 0.96). The bug seems to be that the "private:" doesn't end with the next "}" like it should. For example, this does seem to work: class A { this() {} } class B(): A { private { int foo; } } class C: B!() { this() { printf("C "); } } void main() { C c = new C(); } This bug is similar to another bug report(which also hasn't been fixed yet): digitalmars.D.bugs/793 -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jul 25 2004