O
olanglois
Hi,
I am trying to derive a new class that will add new functions but no
new data members and the base class has overloaded operators
(+,-,+=,-=,etc...) returning either (Base &) or (const Base) depending
on the operator:
class Derived : public Base
{
};
The problem occurs if I do the following
Derived d1,d2;
Derived d3 = d1+d2;
what should be the better approach?
Just add
Derived(const Base&) and
Derived &operator=(const Base&)
or should it be better to redeclare all the operators (there is a lot
of them) in the derived class and perform nothing except calling the
base class version and return Derived reference or object.
Greetings,
Olivier Langlois
http://www3.sympatico.ca/olanglois
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I am trying to derive a new class that will add new functions but no
new data members and the base class has overloaded operators
(+,-,+=,-=,etc...) returning either (Base &) or (const Base) depending
on the operator:
class Derived : public Base
{
};
The problem occurs if I do the following
Derived d1,d2;
Derived d3 = d1+d2;
what should be the better approach?
Just add
Derived(const Base&) and
Derived &operator=(const Base&)
or should it be better to redeclare all the operators (there is a lot
of them) in the derived class and perform nothing except calling the
base class version and return Derived reference or object.
Greetings,
Olivier Langlois
http://www3.sympatico.ca/olanglois
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]