// ClockMain.cpp #include #include Clock.h using namespace std; // Advance the clock by one hour with...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
// ClockMain.cpp #include <iostream> #include "Clock.h" using namespace std; // Advance the clock by one hour with a value parameter void advanceOneHour Val(Clock myClock) { myClock.advanceOneHour(); } // Advance the clock by one hour with a pointer parameter void advanceOneHourPtr(Clock * myClock) { myClock->advanceOneHour(); } // Advance the clock by one hour with a reference parameter void advanceOneHourRef(Clock & myClock) { myClock.advanceOne Hour(); } int main() { } // Create a Clock with ID number 42 clock c1(42); cout << "Setting the clock to 2:03:04 using normal setters" << endl; c1.setHour(2); c1.setMinute (3); c1.setSecond(4); c1.printTime(); cout << "Advancing the clock one hour with a value parameter" << endl; advanceOneHour Val(c1); c1.printTime(); cout << "Advancing the clock one hour with a pointer parameter" << endl; advanceOneHourPtr(&c1); c1.printTime(); cout << "Advancing the clock one hour with a reference parameter" <<endl; advanceOneHourRef(c1); c1.printTime(); cout << "Setting the clock to 8:09:10 with cascading setters << "returning an instance" << endl; c1.setHourIns(8).setMinuteIns(9).setSecondIns(10); c1.printTime(); cout <<"Setting the clock to 5:06:07 with cascading setters << "returning a pointer" << endl; c1.setHourPtr(5).setMinute Ptr(6).setSecondPtr(7); c1.printTime(); 3 " cout << "Setting the clock to 11:12:13 with cascading setters " << "returning a reference" << endl; c1.setHourRef (11).setMinuteRef(12).setSecondRef(13); c1.printTime(); 1. Analyze the output from the function calls in ClockMain.cpp. Which of these function calls compile? Which set the Clock to the correct new time? c1.setHour(2);c1.set Minute(3);c1.setSecond(4); c1.setHourins(8).setMinutelns(9).setSecondins(10); c1.setHourPtr(5).setMinutePtr(6).setSecondPtr(7); c1->setHourPtr(5)->setMinutePtr(6)->setSecondPtr(7); c1.setHourPtr(5)->setMinutePtr(6)->setSecondPtr(7); c1.setHourRef(11).setMinuteRef(12).setSecondPtr(13); advanceOneHourVal(c1); advanceOneHourPtr (&c1); advanceOneHourPtr(c1); advanceOneHourRef(c1); 2. Which of these methods can be declared as const? Why or Why not? Normal Setters Cascading Setters Getters advanceOneHour() Printing Methods Compiles? (YES/NO) Can declare const? (YES/NO) Correct Time? (YES/NO) Why or Why Not? // ClockMain.cpp #include <iostream> #include "Clock.h" using namespace std; // Advance the clock by one hour with a value parameter void advanceOneHour Val(Clock myClock) { myClock.advanceOneHour(); } // Advance the clock by one hour with a pointer parameter void advanceOneHourPtr(Clock * myClock) { myClock->advanceOneHour(); } // Advance the clock by one hour with a reference parameter void advanceOneHourRef(Clock & myClock) { myClock.advanceOne Hour(); } int main() { } // Create a Clock with ID number 42 clock c1(42); cout << "Setting the clock to 2:03:04 using normal setters" << endl; c1.setHour(2); c1.setMinute (3); c1.setSecond(4); c1.printTime(); cout << "Advancing the clock one hour with a value parameter" << endl; advanceOneHour Val(c1); c1.printTime(); cout << "Advancing the clock one hour with a pointer parameter" << endl; advanceOneHourPtr(&c1); c1.printTime(); cout << "Advancing the clock one hour with a reference parameter" <<endl; advanceOneHourRef(c1); c1.printTime(); cout << "Setting the clock to 8:09:10 with cascading setters << "returning an instance" << endl; c1.setHourIns(8).setMinuteIns(9).setSecondIns(10); c1.printTime(); cout <<"Setting the clock to 5:06:07 with cascading setters << "returning a pointer" << endl; c1.setHourPtr(5).setMinute Ptr(6).setSecondPtr(7); c1.printTime(); 3 " cout << "Setting the clock to 11:12:13 with cascading setters " << "returning a reference" << endl; c1.setHourRef (11).setMinuteRef(12).setSecondRef(13); c1.printTime(); 1. Analyze the output from the function calls in ClockMain.cpp. Which of these function calls compile? Which set the Clock to the correct new time? c1.setHour(2);c1.set Minute(3);c1.setSecond(4); c1.setHourins(8).setMinutelns(9).setSecondins(10); c1.setHourPtr(5).setMinutePtr(6).setSecondPtr(7); c1->setHourPtr(5)->setMinutePtr(6)->setSecondPtr(7); c1.setHourPtr(5)->setMinutePtr(6)->setSecondPtr(7); c1.setHourRef(11).setMinuteRef(12).setSecondPtr(13); advanceOneHourVal(c1); advanceOneHourPtr (&c1); advanceOneHourPtr(c1); advanceOneHourRef(c1); 2. Which of these methods can be declared as const? Why or Why not? Normal Setters Cascading Setters Getters advanceOneHour() Printing Methods Compiles? (YES/NO) Can declare const? (YES/NO) Correct Time? (YES/NO) Why or Why Not?
Expert Answer:
Answer rating: 100% (QA)
To answer these questions we need to make some assumptions about the implementation of the Clock class since the actual class definition is not provid... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You receive documents for a new teacher effective September 1, 2023 with 4.25 years and a category rating of Group 2. Calculate the teacher's salary. Please include the calculation. YEA R GROUP 1...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
In this exercise, you will modify the program from Lab10-2. If necessary, create a new project named Intermediate20 Project, and save it in the Cpp8\Chap10 folder. Copy the instructions from the...
-
The functions in Exercises 1128 are all one-to-one. For each function, a. Find an equation for f -1 (x), the inverse function. b. Verify that your equation is correct by showing that f( f -1 (x)) = x...
-
The distance of a lightbulb from a large plane mirror is twice the distance of a person from the plane mirror. Light from the bulb reaches the person by two paths. It travels to the mirror at an...
-
Harvard Products Company produces three products, X, Y, and Z, from a single joint process. The company uses the average unit cost method for allocating the joint production cost. Some spoilage...
-
Use the data set, which represents the ages of 30 executives. Which ages are above the 25th percentile? 43 57 65 47 57 41 56 53 61 54 56 50 66 56 50 61 47 40 50 43 54 41 48 45 28 35 38 43 42 44
-
At Creighton Company, the following errors were discovered after the transactions had been journalized and posted. Prepare the correcting entries. 1. A collection on account from a customer for $870...
-
Mun has given David $15 dollars for lunch. David has to decide to purchase Big Mac instead of KFC. Q1). What is trade-off for David? Q2). What is the opportunity cost for David if he has chosen to...
-
A2 percent increase in the price of milk causes a 4 percent reduction in the quantity demanded of chocolate syrup. What is the cross-price elasticity of demand for chocolate syrup with respect to the...
-
The blue catfish (Ictalurus Furcatus) is the largest species of North Amercian catfish. The current world record stands at 143 pounds, which was caught in the John H. Kerr Reservoir (Bugg's Island...
-
Consider a two-level memory system (i.e., cache and main memory). Assume the cache access time is 3 clock cycles, and the hit rate is 95%. What should be the main memory access time (penalty) to...
-
Before you read this story, this discussion is not focused on politics or the Trump Administration. As you formulate your answer, stick to the regulations only. As you read this article you will...
-
Legal regulations that affect how organizations can compensate employees and provide benefits consider all of these regulations and develop an infographic. the infographic will depict the laws and...
-
Suppose that the missile shown at the right lifts off at t = 0 from the ground and, because it becomes lighter as its fuel is expended, its acceleration (in g's) is given as a function of time in...
-
Managing Human Resources 1. What have you learned ? 2. Discuss why managers have difficulties in managing human resources? 3. How can we achieve employee commitment?
-
(Integrals over Unbounded Regions) Evaluate the following improper dx dy. iterated integral: S0 S (x+1)(y^+1) 8 1 integral as 00
-
Consider the sections of two circuits illustrated above. Select True or False for all statements.After connecting a and b to a battery, the voltage across R1 always equals the voltage across R2.Rcd...
-
Devise a structure declaration that describes a fish. The structure should include the kind, the weight in whole ounces, and the length in fractional inches.
-
Write a program that opens two text files for input and one for output. The program should concatenate the corresponding lines of the input files, use a space as a separator, and write the results to...
-
When are class constructors called? When are class destructors called?
-
In a/an ................ system, neither mass nor energy transfer takes place across its boundary.
-
In a ................, mass, momentum and energy may flow.
-
Potential energy is an ................ property.
Study smarter with the SolutionInn App