As an example, we will use the following C++ code (account.cpp):
#include "account.hpp"Account::Account() : balance(0.0) {}Account::~Account() {}void Account::deposit(const double amount) { balance += amount; }void Account::withdraw(const double amount) { balance -= amount; }double Account::get_balance() const { return balance; }
This code provides the following interface (account.hpp):
#pragma onceclass Account {public: Account(); ~Account(); void deposit(const double amount); void withdraw(const double amount); double get_balance() const;private: double balance;};
Using this example code, we can create bank accounts that start with a balance of zero. We can deposit to and withdraw from an account and also query the account ...