I try to have an operator== called from a derived class
but if i use base class pointers, it does not work, although the objects are created as derived classes
class A
{
public:
bool operator==(const A & other)
{
cout << "this should never been called" << endl;
return this==&other;
}
};
class B : public A
{
public:
bool operator==(const A & other)
{
cout << "this should be called instead" << endl;
return this==&other;
}
};
void process(A _b1,A _b2)
{
if(_b1==_b2)
{
cout << "here" << endl;
}
}
int main()
{
B b1;
B b2;
process(b1,b2);
}
although the operators overload have the same signature, i dont get it
plz help me out
thx