Question
Look at the following class definition, then mark ALL the statements that are legal to have in a program that uses class Change: class Change
Look at the following class definition, then mark ALL the statements that are legal to have in a program that uses class Change:
class Change {
private:
int pennies;
int nickels;
int dimes;
int quarters;
public:
Change() { pennies = nickels = dimes = quarters = 0; }
Change(int p, int n, int d, int q) { pennies = p; nickels = n; dimes = d; quarters = q; }
void add(int p=0, int n=0, int d=0, int q=0)
{ pennies += p; nickels += n; dimes += d; quarters += q; }
void subtract(int p=0, int n=0, int d=0, int q=0)
{ pennies -= p; nickels -= n; dimes -= d; quarters -= q; }
}
1. | Change myMoney (1, 2); |
2. | myMoney.subtract(2); |
3. | myMoney.add(0, 3); |
4. | Change myMoney; |
5. | myMoney.dime++; |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started