how to use the operator of parent class?
c++, inheritance, operators
Solution
Operators of user defined types are just member functions with funky names. So, it goes pretty similarly to your example:
#include <iostream>
class A
{
protected:
A& operator++() { std::cout << "++A\n"; return *this; }
};
class B : public A
{
public:
B& operator++()
{
A::operator++();
return *this;
}
};
int main()
{
B b;
++b;
}
Problem
Possible Duplicate: How to use base class's constructors and assignment operator in C++? ``` class A { protected: void f(); } class B : public A { protected: void f() { A::f(); } } ``` We can use the function of parent class in this way, but I don't know how to use the operator of parent class.