-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
23 lines (16 loc) · 801 Bytes
/
Copy pathAccount.cpp
File metadata and controls
23 lines (16 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
class Account{
protected:
int balance;
public:
Account(); //constructor without parameters
Account(int); //constructor with parameter of starting balance
void withdraw(int); //withdraw method
void deposit(int); //deposit method
int getBalance(); //get the balance and return it
};
Account::Account() : balance(0) {} //initalize the balance to zero
Account::Account(int amount) : balance(amount) {} //constructor initalize the balance to same amount as parameter you set
void Account::withdraw(int amount) {balance -= amount;} //withdraw amount and set balance equal after subtracting
void Account::deposit(int amount) {balance += amount;} //deposit amount and set balance equal after plusing
int Account::getBalance() {return balance;} //return balnace of it