1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#include <iostream>
using namespace std;
class Clock
{
private:
int hours;
int minutes;
int seconds;
public:
//Constructor #1
Clock()
{
hours = 00;
minutes = 00;
seconds = 00;
}
//Constructor #2
Clock(int hr, int min, int sec)
{
hours = hr;
minutes = min;
seconds = sec;
}
void setClock(int, int, int);
};
void Clock::setClock(int hr, int min, int sec)
{
hours = hr;
minutes = min;
seconds = sec;
}
class AlarmClock : public Clock
{
private:
int alarmHours;
int alarmMinutes;
int alarmSeconds;
public:
//Constructor #1
AlarmClock()
{
alarmHours = 00;
alarmMinutes = 00;
alarmSeconds = 00;
}
//Constructor #2
AlarmClock(int hr, int min, int sec)
{
alarmHours = hr;
alarmMinutes = min;
alarmSeconds = sec;
}
void setAlarmClock(int, int, int);
AlarmClock getAlarmClock() const
{
AlarmClock result;
result.alarmHours = alarmHours;
result.alarmMinutes = alarmMinutes;
result.alarmSeconds = alarmSeconds;
return result;
}
};
void AlarmClock::setAlarmClock(int hr, int min, int sec)
{
alarmHours = hr;
alarmMinutes = min;
alarmSeconds = sec;
}
int main()
{
AlarmClock time;
time.setAlarmClock(00, 00, 00);
AlarmClock alarmTime = time.getAlarmClock();
cout << endl;
system("pause");
return 0;
}
|