Object Pointer

Namespace rswhite4 at googlemail.com
Mon Jul 16 00:33:42 PDT 2012


> You cannot have pointers to classes. The language does not 
> support it. You can
> have pointers to class references, and you can have pointers to 
> structs or the
> built-in types, but if Foo is a class, then what you can't have 
> a pointer to
> it. The closest that you can get is that I believe that you can 
> cast class
> references to and from void*, and that will work, but Foo* is a 
> pointer to a
> reference to Foo, not a pointer to Foo, and there's no way in 
> the type system
> to represent a pointer to Foo.
>
> - Jonathan M Davis

Yes. I want a Pointer of Foo's reference, you're right. I think i 
have to move the reference to the heap?


More information about the Digitalmars-d-learn mailing list