January 25, 2002 Nested classes (Java or C++) | ||||
---|---|---|---|---|
| ||||
Are nested classes going to have Java or C++ behaviour ? the following code, will not compiler with two classes that define a nested class with the same name. but operator new require the full name to be supplied, but the class name doe no seem to show that it have been nested, if this desired behaviour or due to the alpha implementation ? class Test { int i; class Foo { int bar; } } // will not compile as Foo's clash! comment is class out to see the other foo's name. class Other { int i; class Foo { int bar; } } int main ( char[][] args ) { /* Object o = new Foo(); // not valid */ Object o = new Test.Foo(); ClassInfo ci = o.classinfo; printf( " class name %s\n", (char*)ci.name ); return 0; } is there a way to get a ClassInfo without an instance of an object ? Mike. |
January 26, 2002 Re: Nested classes (Java or C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | It'll have C++ like behavior, not Java inner classes. To get .classinfo for class Foo without an instance of Foo, use Foo.classinfo. I know this is broke in the current alpha, but I have it fixed and that'll get uploaded soon. "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:a2rnik$184h$1@digitaldaemon.com... > Are nested classes going to have Java or C++ behaviour ? > > the following code, will not compiler with two classes that define a nested > class with the same name. but operator new require the full name to be supplied, but the class name doe no seem to show that it have been nested, if this desired behaviour or due to the alpha implementation ? > > class Test > { > int i; > class Foo > { > int bar; > } > } > > // will not compile as Foo's clash! comment is class out to see the other > foo's name. > class Other > { > int i; > class Foo > { > int bar; > } > } > > > int main ( char[][] args ) > { > /* Object o = new Foo(); // not valid */ > Object o = new Test.Foo(); > ClassInfo ci = o.classinfo; > printf( " class name %s\n", (char*)ci.name ); > return 0; > } > > is there a way to get a ClassInfo without an instance of an object ? > > Mike. > > |
Copyright © 1999-2021 by the D Language Foundation