Hi,
Consider the following code :
When compiling it with VC++ 6, I get the error :
I don't understand the problem, as B inherits
. If I duplicate this routine in B, then there is no errors.
What is behind the problem? Does operators inheritance follows specific rules? Apparently yes, because the following code is valid :
accepts its argument to be covariant, which is forbidden with non-operator routines.
--
Globos
Consider the following code :
Code:
class A
{
public:
virtual A& operator= (const A& other)
{
return *this;
}
};
class B : public A
{
};
int main ()
{
A a;
B b;
b = a;
return 0;
}
Code:
lign(19) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class A' (or there is no acceptable conversion)
Code:
A::operator= (const A& other)
What is behind the problem? Does operators inheritance follows specific rules? Apparently yes, because the following code is valid :
Code:
class A
{
public:
virtual A& operator= (const A& other)
};
class B : public A
{
public:
virtual B& operator= (const B& other)
};
Code:
operator=
--
Globos