March 25, 2008 [Issue 1938] New: member of scope-class-type behavior undefined | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1938 Summary: member of scope-class-type behavior undefined Product: D Version: 1.028 Platform: PC OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: davidl@126.com scope class A { this() { printf("hello!"); } } class B { private: A t; // possible way of embedding A t as C++ class-type // members. in D we only gets A *t corresponding C++ code. // this gives great optimization of not heap allocating // twice. sizeof(B) will count in embeded A members. // in real world each B object gets an A instance embeded, // therefore calling of allocating space for A is saved, // yet you still need to invoke C-tors of A. There init-list // becomes useful. // D2.0 traits stuff should still behave in the old way. public: this() { printf ("B !!"); } } void main() { B b; b = new B; } testd.d(11): variable testd.B.t globals, statics, fields, ref and out parameters cannot be auto testd.d(11): variable testd.B.t reference to scope class must be scope -- |
Copyright © 1999-2021 by the D Language Foundation