#ifndef BANKACCOUNT_H #define BANKACCOUNT_H #include #include using namespace std; class BankAccount { private: string name; protected: double balance; public: BankAccount(string n, double b) : name(n), balance(b) {} BankAccount () : name(""), balance(0.0) {} string getName() const {return name;} double getBalance() const {return balance;} void withDraw(double amount); void deposit(double amount); }; // definitions placed here for convenience. These should go in a .cpp file. void BankAccount::withDraw(double amount){ if (amount <= balance){ balance -= amount; }else{ cout << "insufficient funds" << endl; } } void BankAccount::deposit(double amount){ if(amount >=0){ balance += amount; }else{ cout << " can't deposit a negative amount " << endl; } } #endif