โ Back to Classes
Question 177
Friend Function Comparing Two Objects
Friend Function Comparing Two Objects
A friend function can read the private members of EVERY object passed to it. Create a class Account with a private double balance set by its constructor. Requirements: 1) Constructor Account(double b). 2) A friend function bool isRicher(const Account& a, const Account& b) that returns true if a has a larger balance than b, and false otherwise. Do NOT write a main function.
Expected Output:
true false
Topics:
ClassesFriend Functions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.