readonly?
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jul 11 00:10:34 PDT 2012
On Wednesday, July 11, 2012 09:00:26 Tobias Pankrath wrote:
> Bar b = new Bar;
> auto b2 = &b; // type of b2 is Bar*
>
> So does it meen, that a pointer of type Bar* does not point to
> the real object?
It's a pointer to a reference, not to the object.
> How do I get such a pointer then and which type does it have?
I don't think that you can. It's a reference, not a pointer. And if you _can_
do it, I bet that it's not at all pretty. References are _not_ intended to be
treated the same as pointers. They're similar, but they're fundamentally
different. And instances of classes are intended to be referred to by
references, _not_ be pointed to by pointers.
Rebindable is the correct solution to this "readonly" issue.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list