Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We are currently in class working on classes and constructers. C++ #include using namespace std; class clockType { public: void setTime(int, int, int); void getTime(int&,

image text in transcribedWe are currently in class working on classes and constructers. C++

#include  using namespace std; class clockType { public: void setTime(int, int, int); void getTime(int&, int&, int&) const; void printTime() const; void incrementSeconds(); void incrementMinutes(); void incrementHours(); bool equalTime(const clockType&) const; private: int hr; int min; int sec; }; int main() { clockType myClock; clockType yourClock; int hours; int minutes; int seconds; //Set the time of myClock myClock.setTime(5, 4, 30); //Line 1 cout > hours >> minutes >> seconds; //Line 17 cout  23) hr = 0; } void clockType::incrementMinutes() { min++; if (min > 59) { min = 0; incrementHours(); //increment hours } } void clockType::incrementSeconds() { sec++; if (sec > 59) { sec = 0; incrementMinutes(); //increment minutes } } bool clockType::equalTime(const clockType& otherClock) const { return (hr == otherClock.hr && min == otherClock.min && sec == otherClock.sec); } 
Classes Lab1 In-Class Exercise: Run the example program for the clockType class, with the class definitio class function definitions, and the function main all in the same C++ source file. (See Example 10-2, both editions.) Later, include constructors, in the class functions. Lab to turn in: Add the following to the function main. (1) Declare two clockType objects bigBen and grandfather where the default constructor is used to initialize the data members of bigBen and the constructor with parameters sets the initial data members of grandfather to the time 14:35:59.(2) Print the times of both objects, with labels telling which is which. (3) Increment the time of grandfather by 1 second and print the time for grandfather after the increment. Classes Lab 2 Part 1 In Lab 1, you used one complete file for the clock Type class definition, the class function definitions, and the user's main program which declared and used objects of type clockType. Now, separate the class details from the user's program. Create a header file for the clockType class. definition and the class function definitions. Include the constructors in the class functions Name the file clockType.h and store in it the class Create a main program as before, but do not include the class and class function definitions Insert the line #include "clock-rype.h" before int main) This file is a.cpp source code file, and is entered as usual in Visual C++ 2010. New item there, and paste the header The header file goes in its area in Visual C++. Use Add file lines in. Use Debug to run

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

Identify Freuds developmental stages.

Answered: 1 week ago