For example,
class Person{
string name;
public:
T& operator*(){
return name;
}
bool operator==(const Person &rhs){
return this->name == rhs.name;
}
bool operator!=(const Person &rhs){
return !(*this == rhs); // Will *this be the string name or the Person?
}
}
If *this
ends up dereferencing this
to a string
instead of a Person
, is there a workaround that maintains the usage of *
as a dereference operator outside the class?
It would be quite a hindrance if I couldn't overload *
without giving up usage of *this
.