week_3_lab - / } //funtions #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std class Time { public: void setTime (int, int) void printTime () void incrementMin () void incrementHrs () v Time (int,int) //constuctor with parameters Time () // defalt constructor private: int hour int minute } class extTime:public Time { public: void setTimeZone(char) //new member function specific to the derived class void printTime() //redefining the print member function of the base class private: char TimeZone //new data member specific to the derived class //assumes time zone is denoted by one character } //main #include <iostream> #include "Week3Functions.cpp" #include "Week3Headers.h" using namespace std void main() { //Time firstTime //Time SecondTime / //firstTime.setTime(12,10) //SecondTime.setTime(5,36)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: / } //funtions #include &lt;iostream&gt; #include &quot;Week3Headers.h&quot; Sheet1 Page 2 using namespace std void Time::setTime(int hrs, int min) { if (0 &lt;= hrs &amp;&amp; hrs &lt; 24) hour = hrs else hour = 0 if (0 &lt;= min &amp;&amp; min &lt; 60) minute = min else minute = 0 } void Time::getTime(int&amp; hrs, int&amp; min) { hrs = hour min = minute } void Time::printTime() { //is taken whether the hrs and min are 1 or 2 digits if (hour &lt; 10) cout&lt;&lt;&quot;0&quot; cout&lt;&lt;hour&lt;&lt;&quot;:&quot; hour = 0 if (minute &lt; 10) cout&lt;&lt;&quot;0&quot; cout&lt;&lt;minute&lt;&lt;&quot;:&quot; minute = 0 } void Time::incrementHrs() { hour++ if (hour &gt; 23) hour = 0 } void Time::incrementMin() { minute++ if (minute &gt; 23) minute = 0 } void extTime::printTime() { Time::printTime() cout&lt;&lt;&quot; Time Zone = &quot;&lt;&lt; TimeZone }...
View Full Document

Page1 / 2

week_3_lab - / } //funtions #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online