Thanks!
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
#include "Time.h"
Time::Time( int hour, int minute )
{
hour = 0;
minute = 0;
}
istream & operator>> (istream & in, Time & t)
{
string time;
string hour;
string minute;
int timehour;
int timeminute;
in >> time;
hour = time.substr(0,2);
minute = time.substr(3,2);
timehour = atoi(hour.c_str());
timeminute = atoi(minute.c_str());
t.hour = timehour;
t.minute = timeminute;
return in;
}
ostream & operator<< (ostream & out, Time & t)
{
out << t.hour << " : " << t.minute << endl;
return out;
}
This post has been edited by react05: 15 February 2010 - 07:01 PM

New Topic/Question
Reply




MultiQuote








|