struct Data
{
std::string Info; // Object Info
virtual bool operator==(Data& b)
{
return this->Info == b.Info;
}
};
struct Data1: public Data
{
int ID;
virtual bool operator==(Data1& b) override // overrides the bool operator==(Data& b) base function
{
return (this->Info == b.Info) && (this->ID);
}
};
The above code won't compile, I am wandering if it is possible to do so?
I would like my virtual operator function not be class bound.
In other words, maybe something like a template virtual (doesn't exist). I have tried template but of course virtual cannot be paired with template.
struct Data
{
std::string Info; // Object Info
template <class T>
virtual bool operator==(T& b)
{
return this->Info == b.Info; // something along the line
}
};
struct Data1: public Data
{
int ID;
virtual bool operator==(Data1& b) override // overrides the bool operator==(Data& b) base function
{
return (this->Info == b.Info) && (this->ID);
}
};