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?

Thanks

Reply via email to