#include <iostream>
struct Monsters
{
int Damage;
int PowerUp;
int Monster_Strength;
// remaining members elided for brevity
Monsters( int d, int p, int ms ) : Damage(d), PowerUp(p), Monster_Strength(ms) {}
};
bool operator== ( const Monsters& a, const Monsters& b ) // C++11
{
return a.Damage == b.Damage && a.PowerUp == b.PowerUp &&
a.Monster_Strength == b.Monster_Strength ;
}
bool operator!= ( const Monsters& a, const Monsters& b ) { return !(a==b) ; }
int main()
{
Monsters m11( 23, 2, 5 ) ; // *** note this - () instead of {}
if( m11 == Monsters( 23, 2, 5 ) ) std::cout << "ok\n" ;
if( m11 != Monsters( 23, -6, 5 ) ) std::cout << "ok\n" ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IE1vbnN0ZXJzCnsKICAgIGludCBEYW1hZ2U7CiAgICBpbnQgUG93ZXJVcDsKICAgIGludCBNb25zdGVyX1N0cmVuZ3RoOwoKICAgIC8vIHJlbWFpbmluZyBtZW1iZXJzIGVsaWRlZCBmb3IgYnJldml0eQoKICAgIE1vbnN0ZXJzKCBpbnQgZCwgaW50IHAsIGludCBtcyApIDogRGFtYWdlKGQpLCBQb3dlclVwKHApLCBNb25zdGVyX1N0cmVuZ3RoKG1zKSAgICB7fQp9OwoKYm9vbCBvcGVyYXRvcj09ICggY29uc3QgTW9uc3RlcnMmIGEsIGNvbnN0IE1vbnN0ZXJzJiBiICkgLy8gQysrMTEKewogICAgcmV0dXJuIGEuRGFtYWdlID09IGIuRGFtYWdlICYmIGEuUG93ZXJVcCA9PSBiLlBvd2VyVXAgJiYKICAgICAgICAgICBhLk1vbnN0ZXJfU3RyZW5ndGggPT0gYi5Nb25zdGVyX1N0cmVuZ3RoIDsKfQoKYm9vbCBvcGVyYXRvciE9ICggY29uc3QgTW9uc3RlcnMmIGEsIGNvbnN0IE1vbnN0ZXJzJiBiICkgeyByZXR1cm4gIShhPT1iKSA7IH0KCmludCBtYWluKCkKewogICAgTW9uc3RlcnMgbTExKCAyMywgMiwgNSApIDsgLy8gKioqIG5vdGUgdGhpcyAtICgpIGluc3RlYWQgb2Yge30KICAgIGlmKCBtMTEgPT0gTW9uc3RlcnMoIDIzLCAyLCA1ICkgKSBzdGQ6OmNvdXQgPDwgIm9rXG4iIDsKICAgIGlmKCBtMTEgIT0gTW9uc3RlcnMoIDIzLCAtNiwgNSApICkgc3RkOjpjb3V0IDw8ICJva1xuIiA7Cn0K