#include #include #include using namespace std; class Transaction //Classs declaration { private: //Private variables int amount; string type; public: //Public variables Transaction(int amt, string t) :amount(amt), type(t) //we are using lazy initialization here {}; string Report() { string report; report = " "; report += type; report += " "; report += to_string(amount); return report; }; }; class Account //Declaring the class { private: int balance; vector log; public: Account() //This is a constructor { balance = 0; }; vector Report()//Functions that is going to return a vector of strings { vector report; report.push_back("Current Balance is " + to_string(balance)); report.push_back("Transactions: "); for (auto t : log) { report.push_back(t.Report()); } report.push_back("_______________"); return report; }; bool Deposit(int amt)//Deposit function { if (amt >= 0) { balance += amt; log.push_back(Transaction(amt, "Deposit")); return true; } else { return false; } }; bool Withdraw(int amt) { if (amt >= 0) { if (balance >= amt) { balance -= amt; log.push_back(Transaction(amt, "Withdraw")); return true; } else { return false; } } else { return false; } }; //Withdraw function }; int main() { Account a1; a1.Deposit(90); cout << "After depositing £90" << endl; for (auto s : a1.Report()) { cout << s << endl; } a1.Withdraw(50); cout << "After withdrawing £50" << endl; for (auto s : a1.Report()) { cout << s << endl; } return 0; }