Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Acount
  6. {
  7.     string name;
  8.     int money = 0;
  9.     static int bonus;
  10. public:
  11.     Acount(string name, int money)
  12.     {
  13.         this->name = name;
  14.         this->money = money + bonus;
  15.     }
  16.  
  17.     static int getBonus() {
  18.         return bonus;
  19.     }
  20.  
  21.     static void setBonus(int _bonus){
  22.         bonus = _bonus;
  23.     }
  24.     int getMoney() {
  25.         return money;
  26.     }
  27.  
  28. };
  29. int Acount::bonus = 50;
  30. int main() {
  31.     setlocale(LC_ALL, "Russian");
  32.     Acount c1("Глеб", 20);
  33.     Acount c2("Ярик", 100);
  34.     Acount c3("Фокин", 80);
  35.     cout << c1.getMoney() << endl;
  36.     cout << c2.getMoney() << endl;
  37.     cout << c3.getMoney() << endl;
  38.  
  39.     system("pause");
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement