Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string>
- using namespace std;
- class Time
- {
- public:
- void setHour(int);
- void setMinute(int);
- int getHour();
- int getMinute();
- void incrHour(int);
- void incrMinute(int);
- void printTime();
- int addHr(){ return hr;};
- int addMin() {return min;};
- Time(int hr, int min);//regular constructor
- Time();//default constructor
- private:
- int hr, min;
- };
- class ExtTime
- {
- public:
- ExtTime(int hr, int min);
- void timeZone(int, int);
- void printTime();
- private:
- string zone;
- int hr, min;
- };
- void Time::setHour(int)
- {
- cout << "Enter the hour: ";
- cin >> hr;
- }
- void Time::setMinute(int)
- {
- cout << "Enter the minutes: ";
- cin >> min;
- }
- void Time::incrHour(int addHr)
- {
- hr++;
- if (hr==24)
- hr= 0;
- }
- void Time::incrMinute(int addMin)
- {
- min++;
- if(min==60)
- {
- hr++;
- min=0;
- if(hr==24)
- hr=0;
- }
- }
- void Time::printTime()
- {
- cout << "In Eastern Standard Time the time is: ";
- if(hr < 10)
- cout << "0";
- cout << hr << ":";
- if(min < 10)
- cout << "0";
- cout << min;
- }
- void ExtTime::timeZone(int, int)
- {
- cout<<"Enter time zone (EST, PST, MST, CST):";
- cin>> zone;
- if (zone == "PST")
- cout << "The time is: " << (hr-3) << ":" << min << endl;
- if (zone == "EST")
- cout << "The time is: " << hr << ":" << min << endl;
- if (zone == "CST")
- cout << "The time is: " << (hr-1) << ":" << min << endl;
- if (zone == "MST")
- cout << "The time is: " << (hr-2) << ":" << min << endl;
- else cout << "error" << endl;
- }
- int main()
- {
- Time myTime;
- myTime.setHour();
- myTime.setMinute();
- int hr = myTime.getHour();
- int min = myTime.getMinute();
- cout << "The hour is " << hr << " and the minute is " << min << endl;
- myTime.printTime();
- cout << endl;
- myTime.addHr();
- cout << "After adding 1 hour\n";
- myTime.printTime();
- cout << endl;
- myTime.addMin();
- cout << "After adding 1 minute\n";
- myTime.printTime();
- cout << hr;
- cout << min;
- cout << endl;
- ExtTime newTime(hr,min);
- newTime.timeZone(hr,min);
- }
1>c:\users\amber\documents\visual studio 2008\projects\week4_amber nelson\week4_amber nelson\week4_ambernelson.cpp(96) : error C2660: 'Time::setHour' : function does not take 0 arguments
1>c:\users\amber\documents\visual studio 2008\projects\week4_amber nelson\week4_amber nelson\week4_ambernelson.cpp(97) : error C2660: 'Time::setMinute' : function does not take 0 arguments
I am just starting to learn and I am a bit confused..