Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Account {
- string nickname;
- static int bonus;
- int money = 0;
- public:
- Account(string nickname, int money) {
- this->nickname = nickname;
- this->money = money + bonus;
- }
- static void setBonus(int _bonus) {
- bonus = _bonus;
- }
- static int getBonus() {
- return bonus;
- }
- int getMoney() {
- return money;
- }
- };
- int Account::bonus = 10;
- int main() {
- Account n1("papa1", 30);
- Account n2("papa2", 100);
- Account n3("papa3", 75);
- cout << n1.getMoney() << endl;
- cout<< n2.getMoney() << endl;
- cout << n3.getMoney() << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement