Write the following in C++ Existing class and code have been provided. • In addi
ID: 3712052 • Letter: W
Question
Write the following in C++
Existing class and code have been provided.
• In addition to hours, minutes, and seconds, it is required to store the time zone. Derive
a class named classextClockType from the base class clockType by adding a
member variable to store the time zone.
• Add the necessary member functions:
– "setTime" function
– "printTime" function
and constructors to make the class functional.
• Write the definitions of the mentioned member functions and the constructors.
• Write a test program to test your class.
• Do not use any global variable and comment your code. Do not modify any members
of the base class.
------------------------------clockType.h-----------------------
-----------------------------clockTypeImp.cpp----------------------
-------------------------testClockClass.cpp-------------------
Explanation / Answer
class classextClockType: public clockType
{
char *timeZone;
public:
void setTime(char* x)
{
strcpy(timeZone,x);
}
void printTime()
{
cout<<hr<<":"<< min<< ":"<<sec<<" "<<timeZone;
}
classextClockType(char* s)
{
strcpy(timeZone,s);
}
classextClockType(char* s)
{
strcpy(timeZone,"Default");
}
};
int main()
{
classextClockType T;
t.printTime();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.