SHARE
TWEET

Untitled

a guest Jan 21st, 2020 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. class cAccount {
  4. private:
  5.     unsigned long long accountId;
  6.     double accountBalance;
  7.  
  8. public:
  9.     cAccount(unsigned long long id, double balance = 0.0):
  10.         accountId{ id }, accountBalance{ balance } { }
  11.     ~cAccount() = default;
  12.  
  13.     unsigned long long id() const {
  14.         return accountId;
  15.     }
  16.  
  17.     double balance() const {
  18.         return accountBalance;
  19.     }
  20.  
  21.     double balance(double newBalance) {
  22.         if (newBalance >= 0.0)
  23.             accountBalance = newBalance;
  24.         return accountBalance;
  25.     }
  26. };
  27.  
  28. int main() {
  29.  
  30.     cAccount acc(1263721);
  31.     cAccount bcc(1273812);
  32.  
  33.     bcc.balance(72);
  34.     acc.balance(bcc.balance);
  35.  
  36.     std::cout << acc.id() << " has " << acc.balance() << "\n";
  37.     std::cout << bcc.id() << " has " << bcc.balance() << "\n";
  38.  
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top