MasterGun

In-Game Bonus

Apr 4th, 2020 (edited)
172
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Account
  2. {
  3.     string nick;
  4.     int money;
  5.     static int bonus;
  6. public:
  7.     Account(string nick, int money)
  8.     {
  9.         this->nick = nick;
  10.         this->money = money+bonus;
  11.     }
  12.     static int getBonus()
  13.     {
  14.         return bonus;
  15.     }
  16.     static void setBonus(int _bonus)
  17.     {
  18.         bonus = _bonus;
  19.     }
  20.     void showinfo()
  21.     {
  22.         cout << nick << endl;
  23.         cout << money << endl;
  24.         cout << bonus << endl;
  25.     }
  26. };
  27. int main(){
  28. int Account::bonus = 200;
  29. int main(){
  30.     Account p1("Sanya", 0);
  31.     Account p2("Yura", 100);
  32.     Account p3("Gleb", 50);
  33.  
  34.     Account setBonus();
  35.     Account getBonus();
  36.     p1.showinfo();
  37.     p2.showinfo();
  38.     p3.showinfo();
  39. return 0;
  40. }
RAW Paste Data