If I have the given below classes:
class TestA
{
public:
const TestA &operator=(const int A){return *this;}
};
class TestB : public TestA
{
public:
//Inheritance?
};
The question presumes both class TestA and class TestB have exactly the same contents in terms of variables: Is the assignment operator (or any other operator) inherited?
Is the following valid?
class TestB : public TestA
{
public:
using TestA::operator=;
//Inheritance?
};
If it is valid, would it make a difference?
Assignment operators are hidden by derived class by default (as compiler always generates a
T& operator = ()for anyclass T, if not specified). Which makes the inheritedoperator =not usable.Yes when you specify them with
usingkeyword; they become usable. Demo. So your code snippet does make sense.