Why can't we define re-assignable const reference variable?
none
z at gg.com
Sun Feb 17 11:08:05 PST 2008
> == Quote from Janice Caron (caron800 at googlemail.com)'s article
> > But I just want to clear up one misconception. You /cannot/ do that in
> > C++. References in C++ are /never/ rebindable.
>
> That's a terminology issue, to make it clear:
> class C {}
> D C++
> ========================= ===========================
> reference: C c = new C(); pointer: C *c = new C();
> pointer: C* cp = &c; ptr-to-ptr: C **cp = &c;
I just want to make it clear again, nobody has what you called 'misconception'.
By using my table, I'm saying '_reference_ in D is similar to _pointer_ in C++'!
I think you have a 'misconception' that '_reference_ in D is similar to
_reference_ in C++'!
Just as you said: "References in C++ are /never/ rebindable"; but '(non-const)
reference in D' is rebindable
class C {}
C c;
c = c1;
c = c2; // rebind!
So '_reference_ in D is similar to _pointer_ in C++', not reference in C++!
Since 'in C++, const C* p; // non-const pointer, const data' is allowed, why
cannot we have 'non-const reference, const data' in D?
More information about the Digitalmars-d
mailing list