Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose your program contains the following class defirution. class yourclass {

ID: 3694984 • Letter: S

Question

Suppose your program contains the following class defirution. class yourclass { public: YourClass(int new_lafor, char mors_new_info): YourClass(): vaid do_stuff(); private; int information; char more_information; } Which of the following are legal? (a) YourClass an_object (42, 'A'); (b) YourClass another_object; (c) an_object = YourClass (99, 'B'); (d) an_object = YourClass (); (e) an_object = YourClass; 9. If one more overloading function will be added, then, declare and define the overloading function to overload the operator so that the precondition is amount 1 and amoung 2 have been given values. The post-condition is that the overloading function returns true if amount 1 is less than amount 2, otherwise, returns false, amount 1 and amount 2 are from Money class. Ther is only one private member, all_cents in the class Money. Declare: Define: 10. Write a program that reads in five amounts of money, doubles each amount, and then writes out the doubled values to the screen. Use one array with Money as the base type. Assume that the class, Money, is given as the textbook. class Money ( public: friend Money operator + (const Money& amountf, cost Money& amount2); friend Money operator -(const Money& amount1, const Money& amount2); friend Money operator -(const Money& amount);

Explanation / Answer

8.

a. YourClass an_object(42, 'A'); //Legal. Calls the parameterized constructor.
YourClass another_object; //Legal. Just creates an object but not initializes.
an_object = YourClass(99, 'B'); //Legal. Initializes the object with parameterized constructor.
an_object = YourClass(); //Legal. Initializes the object with default constructor.
an_object = YourClass; //Illegal. YourClass is an datatype, and should not be assigned.

9.

Declaration is:

bool Money operator<(const Money &amount1, const Money &amount2);

Definition is:

bool Money operator<(const Money &amount1, const Money &amount2)
{
if(amount1.getAllCents() < amount2.getAllCents())
return true;
return false;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote