| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <iostream>
- #include <vector>
- struct Account
- {
- int id;
- int value;
- Account() :
- id(-1),
- value(0)
- {
-
- }
- friend std::ostream& operator << (std::ostream& p_os, const Account& p_account)
- {
- p_os << "[" << p_account.id << "] - [" << p_account.value << "]";
- return (p_os);
- }
- };
- struct Bank
- {
- int liquidity;
- std::vector<Account *> clientAccounts;
- Bank() :
- liquidity(0)
- {
- }
- friend std::ostream& operator << (std::ostream& p_os, const Bank& p_bank)
- {
- p_os << "Bank informations : " << std::endl;
- p_os << "Liquidity : " << p_bank.liquidity << std::endl;
- for (auto &clientAccount : p_bank.clientAccounts)
- p_os << *clientAccount << std::endl;
- return (p_os);
- }
- };
- int main()
- {
- Account accountA = Account();
- accountA.id = 0;
- accountA.value = 100;
- Account accountB = Account();
- accountB.id = 1;
- accountB.value = 100;
- Bank bank = Bank();
- bank.liquidity = 999;
- bank.clientAccounts.push_back(&accountA);
- bank.clientAccounts.push_back(&accountB);
- bank.liquidity -= 200;
- accountA.value += 400;
- std::cout << "Account : " << std::endl;
- std::cout << accountA << std::endl;
- std::cout << accountB << std::endl;
- std::cout << " ----- " << std::endl;
- std::cout << "Bank : " << std::endl;
- std::cout << bank << std::endl;
- return (0);
- }
|