Code:
SHORT Platform::operator==(Platform q)
{
if(q.GetX() == this->GetX() && q.GetY() == this->GetY() && q.GetStr() == this->GetStr() &&
q.GetWStatus() == this->GetWStatus)
return 1;
return 0;
}
GetWStatus is a function, you need to use this->GetWStatus() and not this->GetWStatus.
Code:
SHORT Platform::IsNull() {
static Platform K(-1, 0, 0, 0);
if(this == K)
return 1;
return 0;
}
Again, you're forgetting that this is a pointer and not an object of type Platform. Coupled with how you have defined the operator (as a member function), you would need to say if( this->operator==(K) ). You should make your operators global friend functions as such:
Code:
class Platform
{
...
friend bool operator==(const Platform&, const Platform&);
};
bool operator==(const Platform& lhs, const Platform& rhs)
{
if(lhs.GetX() == rhs.GetX() && lhs.GetY() == rhs.GetY() && lhs.GetStr() == rhs.GetStr() &&
lhs.GetWStatus() == rhs.GetWStatus())
return true;
else return false;
}
This will allow you to compare two Platform objects directly using == and say things like:
Code:
Platform foo(-1,0,0,0);
Platform bar(-1,0,0,0);
...
if( foo == bar )
...
... without needing the awkward syntax if( foo->operator==(bar) ) that wouild otherwise be required.
This will also require you make all your "get" member functions const correct as they should have been all along:
Code:
class Platform {
...
SHORT GetX() const {return x;}
SHORT GetY() const {return y;}
SHORT GetStr() const {return Strength;}
SHORT GetWStatus() const {return SteppedOn;}
};