i guess you would have that operator defined in the derived class and it would output all the members from the derived class and also it would output the members from the base class. it would access the members from base class using scope resolutor operator :: like so:
#include <iostream>
using namespace std;
class base
{
protected:
int a, b, c;
public:
base():a(1),b(2),c(3){}
/* some functions */
};
class derived : public base
{
private:
int a,b,c; //totally different from base class members
public:
derived():a(4),b(5),c(6){}
/*i've kept things simple by using ++ operator as it is unary. using << for this example
would complicate things so please do substitute << in your own program as
it is not recommended to use operators this way. this is just an example */
void operator ++ ()
{
cout<<a<<b<<c;
cout<<base::a<<base::b<<base::c;
}
};
int main()
{
base b;
derived d;
++d;
/* ++d here displays 456123*/
return 0;
}
this way you only use an operator once on the derived class but make it access or perform operations on the base class as well at the same time. I do wonder tho if anyone would need to do that in the real world, but you never know... I din't really put any thought into this so it's not well planned but it does answer the question. hope it helps