Skip to content

Instantly share code, notes, and snippets.

@AungWinnHtut
Created February 3, 2019 11:00
Show Gist options
  • Save AungWinnHtut/bc9130d9a8ce967d5bf1a043d84a1192 to your computer and use it in GitHub Desktop.
Save AungWinnHtut/bc9130d9a8ce967d5bf1a043d84a1192 to your computer and use it in GitHub Desktop.
time cpp
#include "Time.h"
#include<iostream>
#include<string>
void Time::Clear() {
hour = 0;
minute = 0;
}
Time::Time() {
Clear();
}
Time::~Time() { }
Time::Time(int hh, int min) {
hour = hh;
minute = min;
}
void Time::setHour(int hh) {
hour = hh;
}
void Time::setMinute(int min) {
minute = min;
}
void Time::setTime(int hh, int min) {
setHour(hh);
setMinute(min);
}
int Time::getHour() {
return hour;
}
int Time::getMinute() {
return minute;
}
std::ostream& operator << (std::ostream& oObject, Time &time1) {
oObject << time1.getHour() << ":" << time1.getMinute() << endl;
return oObject;
}
std::istream& operator >> (std::istream& iObject, Time &time1) {
int hour1, min1;
iObject >> hour1 >> min1;
time1.setHour(hour1);
time1.setMinute(min1);
return iObject;
}
#ifndef TIME_H
#define TIME_H
#include<iostream>
#include<string.h>
using namespace std;
class Time {
public:
Time();
void Clear();
~Time();
Time(int hh, int min);
void setHour(int hh);
void setMinute(int min);
void setTime(int hh, int min);
int getHour();
int getMinute();
private:
int hour;
int minute;
};
std::ostream& operator << (std::ostream& oObject, Time &time1);
std::istream& operator >> (std::istream& iObject, Time &time1);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment