Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class cAccount {
- private:
- unsigned long long accountId;
- double accountBalance;
- public:
- cAccount(unsigned long long id, double balance = 0.0):
- accountId{ id }, accountBalance{ balance } { }
- ~cAccount() = default;
- unsigned long long id() const {
- return accountId;
- }
- double balance() const {
- return accountBalance;
- }
- double balance(double newBalance) {
- if (newBalance >= 0.0)
- accountBalance = newBalance;
- return accountBalance;
- }
- };
- int main() {
- cAccount acc(1263721);
- cAccount bcc(1273812);
- bcc.balance(72);
- acc.balance(bcc.balance);
- std::cout << acc.id() << " has " << acc.balance() << "\n";
- std::cout << bcc.id() << " has " << bcc.balance() << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement