Tyro[a.c.edwards] <[email protected]> wrote:
class Class{}void main() { Class myClass; Class* pClass0 = &myClass; // OK Class* pClass1 = new Class; // Error: cannot implicitly convert [8] // expression (new Class) of type t.Class // to test.Class* Class* pClass2 = &(new Class); // Error: new Class is not an lvalue [12] Class mClass = &(new Class);// Error: cannot implicitly convert [14] // expression (&new Class) of type Class* // to test.Class }C++ uses the process on line [8] above to initialize a class pointer. Obviously it does not work in D. But given the error message at [14], I thought [12] would have been allowed. What is the proper way to convert [8] to D?
Classes in D are already references (like Class& in C++), thus line [8] would be a pointer to a reference to a class, something which may make some kind of sense, but is unlikely to be what you want. Perhaps this question is better answered if you explain why you want a pointer to a class? -- Simen
