//STARTSOLUTION #include //ENDSOLUTION #include using namespace std; //STARTSOLUTION class Healthbar { public: Healthbar(string const& name, int hp) : name{name}, hp{hp} {} Healthbar& operator+=(int damage) { hp += damage; return *this; } Healthbar operator+(int damage) { return Healthbar{name, hp} += damage; } Healthbar& operator++() { return *this += 1; } Healthbar operator++(int) { Healthbar tmp{*this}; ++*this; return tmp; } friend ostream& operator<<(ostream& os, Healthbar const& healthbar) { return os << healthbar.name << " - " << healthbar.hp << " hp"; } private: string name; int hp; }; Healthbar operator+(int damage, Healthbar& healthbar) { return healthbar + damage; } //ENDSOLUTION int main() { Healthbar bar1{"Gimlis Health", 5}; cout << bar1 << endl; bar1 += 1; cout << bar1 << endl; Healthbar bar2 = bar1 + 1; cout << bar1 << endl; cout << bar2 << endl; Healthbar bar3 = 1 + bar1; cout << bar1 << endl; cout << bar3 << endl; ++bar1; cout << bar1 << endl; bar1++; cout << bar1 << endl; }