Mailinglist Archive: opensuse-programming (105 mails)

< Previous Next >
Curiosity on covariant return type (C++)
  • From: Verdi March <cincaipatron@xxxxxxx>
  • Date: Wed, 2 Jul 2003 22:55:39 +0800
  • Message-id: <200307022255.39421.cincaipatron@xxxxxxx>
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.

--

-- Verdi March --


< Previous Next >
Follow Ups