On Wednesday 02 July 2003 14:55, Verdi March wrote:
Hi,
just curious, when I tried this trick on function returning referenceg++ failed. Also, when I searched in Google, all examples use functions that return a pointer.
class Base { virtual Base& getRef() const = 0; virtual Base* getPtr() const = 0; }
class Derived : public Base{ virtual Derived& getRef() const; //This one does not work. virtual Derived* getPtr() const; }
Perhaps someone knows the exact definition (standard/ISO) of this -- is reference allowed or only pointer allowed?
TIA.
I don't know the ISO defn, but does returning a const ref make any sense? I'd guess the constness would to apply to the reference itself, rather than the data it refers to, which probably isn't what you'd want. But you've got me wondering now... Arthur