// 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...
-
Can variability be negative? Explain.
-
In what ways are First Amendment protections limited?
-
\(14 \times(3 \sqrt{2}+11.6)=14 \times 3 \sqrt{2}+14 \times 11.6\) Identify the property of real numbers that is being illustrated.
-
A job order cost sheet for Lowry Company is shown below. Instructions (a) On the basis of the foregoing data, answer the following questions. (1) What was the balance in Work in Process Inventory on...
-
operations in synthetic fibre manufacturing. Your boss comes into your office, drops a consultant's report on your desk, and complains, "We owe these consultants $1.9 million for this report, and I...
-
1. Using the spreadsheet model from Case 2.1 as a starting point, use Solver to find the optimal set of projects to approve. The solution should maximize the total NPV from the approved projects, and...
-
Which of the following methods does NOT call for the elimination of ALL intercompany profits? A) Identifiable net asset method B) Fair value enterprise method C) Proportionate consolidation method D)...
-
What variables to consider to carry out the Dupont method in finance? Explain.
-
If Blossom Ink, Inc. has net sales of $ 3 7 5 0 0 0 and cost of goods sold of $ 3 0 3 7 5 0 , the company\'s gross profit rate is 2 3 % . 1 9 % . 1 0 0 % . 8 1 % .
-
Recent Merger and Acquisition (M&A) Activities, Evaluate the effect of interest rates and time value of money by presenting a summary of recent M&A activities for Verizon & A&Ts. Summary should...
-
A risk-free, zero-coupon bond with a face value of $5,000 has 10 years to maturity. If the YTM is 4.5%, what price is this bond will trade at?
-
2 2 . Where do you enter the employee default deductions? 2 3 . What linked accounts must you set up for import duties? 2 4 . How does historical payroll information affect the employees T 4 ? 2 5 ....
-
Construct a regression model without interactions using all predictors (e.g., length, height, width). Clearly define your variables and write out the regression equation. Interpret the meaning of the...
-
A regular deposit of $100 is made at the beginning of each year for 20 years. Simple interest is calculated at i% per year for the 20 years. At the end of the 20-year period, the total interest in...
-
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?
-
\(\sim(\sim r \vee \sim s)\) Given: \(p\) : Frodo is a hobbit, \(q\) : Gandalf is a wizard, \(r\) : Frodo and Samwise will take the ring to Mordor, and \(s\) : Gollum will help Frodo get into Mordor....
-
\(p \vee q \leftrightarrow r\) Given: \(p\) : Frodo is a hobbit, \(q\) : Gandalf is a wizard, \(r\) : Frodo and Samwise will take the ring to Mordor, and \(s\) : Gollum will help Frodo get into...
-
Frodo and Samwise will take the ring to Mordor or Gandalf is not a wizard and Frodo is a hobbit. Translate the written form of each compound logical statement into symbolic form.
Study smarter with the SolutionInn App