another compiler bug?

torhu no at spam.invalid
Wed Jan 9 18:30:59 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.


Do you actually want to heap allocate a pointer to an object reference? 
  Try this:

A* cp = *(new A*);

Maybe you really wanted to take the allocate an object, and then get the 
address of the reference?  I guess so, but I don't know if that's 
possible in a single statement.


More information about the Digitalmars-d-learn mailing list