Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How flying airoplane?

Answered: 1 week ago

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago