#include <iostream>
struct Monsters
{
public:
int Damage;
int PowerUp;
int Monster_Strength;
int hp;
int lvl;
int money;
int defense;
};
#include <tuple>
bool operator== ( const Monsters& a, const Monsters& b ) // C++11
{
static const auto to_tuple = [] ( const Monsters& m )
{
return std::make_tuple( m.Damage, m.PowerUp, m.Monster_Strength, m.hp,
m.lvl, m.money, m.money, m.defense ) ;
};
return to_tuple(a) == to_tuple(b) ;
}
// principle of least surprise
bool operator!= ( const Monsters& a, const Monsters& b ) { return !(a==b) ; }
int main()
{
Monsters m11 = { 23, 2, 5, 8, 19, 7, 9 } ;
if( m11 == Monsters{ 23, 2, 5, 8, 19, 7, 9 } ) std::cout << "ok\n" ; // C++11
if( m11 != Monsters{ 23, 2, 5, -9, 19, 7, 9 } ) std::cout << "ok\n" ; // C++11
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IE1vbnN0ZXJzCnsKICAgIHB1YmxpYzoKCQlpbnQgRGFtYWdlOwoJCWludCBQb3dlclVwOwoJCWludCBNb25zdGVyX1N0cmVuZ3RoOwoJCWludCBocDsKCQlpbnQgbHZsOwoJCWludCBtb25leTsKCQlpbnQgZGVmZW5zZTsKfTsKCiNpbmNsdWRlIDx0dXBsZT4KCmJvb2wgb3BlcmF0b3I9PSAoIGNvbnN0IE1vbnN0ZXJzJiBhLCBjb25zdCBNb25zdGVycyYgYiApIC8vIEMrKzExCnsKICAgIHN0YXRpYyBjb25zdCBhdXRvIHRvX3R1cGxlID0gW10gKCBjb25zdCBNb25zdGVycyYgbSApCiAgICB7CiAgICAgICAgcmV0dXJuIHN0ZDo6bWFrZV90dXBsZSggbS5EYW1hZ2UsIG0uUG93ZXJVcCwgbS5Nb25zdGVyX1N0cmVuZ3RoLCBtLmhwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG0ubHZsLCBtLm1vbmV5LCBtLm1vbmV5LCBtLmRlZmVuc2UgKSA7CiAgICB9OwogICAgcmV0dXJuIHRvX3R1cGxlKGEpID09IH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