another compiler bug?

Robert DaSilva sp.unit.262+digitalmars at gmail.com
Wed Jan 9 16:54:17 PST 2008


Aarti_pl wrote:
> How to create pointer to class?
> 
> Below doesn't compile:
> ----
> A* cp = new A*;
> ----
> Type of new A* is (A**) while it should be A*.
> 
> Any comments? (Maybe I missed something...)
> 
> PS. I know that it is possible to create pointer to class in two steps.
> 
> BR
> Marcin Kuszczak
> (aarti_pl)

Because new returns a pointer to what you ask for. The reason new
returns A when you ask it for A instead of *A like it would with
anything else (anything not a class), is because A is actually a pointer
to an instance of class A.

The true is this is probably the best behaver, maybe... This raise some
important question, I think.


More information about the Digitalmars-d-learn mailing list