Homework question regarding Time

I am making a class called Time in C++ and the class has 3 integers as private member variables. I am pretty new at using classes in C++ and am trying to figure out how to solve this particular problem. The problem is that when I try to do this:

#include <iostream>
#include <cctype>
#include <cstdlib>
using namespace std;

class Time
{
private:
int hours;
int minutes;
int seconds;
void normalize();
public:
Time() {hours = minutes = seconds = 0; normalize();};
Time(int a, int b, int c);
friend Time operator + (const Time& t1, const Time& t2);
friend Time operator - (const Time& t1, const Time& t2);
friend bool operator < (const Time& t1, const Time& t2);
friend istream& operator >>(istream& ins, Time& t1);
friend ostream& operator <<(ostream& out, Time& t1);
};

Time::Time(int a, int b, int c)
{
hours = a;
minutes = b;
seconds = c;

normalize();
}

void Time::normalize()
{
int s = seconds;
int m = minutes;
int h = hours;

while(s < 0)
{
s += 60;
m--;
}

while(m < 0)
{
m += 60;
h--;
}

while(h < 0)
{
h = h + 24;
}

seconds = s % 60;
minutes = (m + s/60) % 60;
hours = (h + m/60 + s/3600) % 24;
}

istream& operator >>(istream& ins, Time& t1)
{
ins >> t1.hours;
ins >> t1.minutes;
ins >> t1.seconds;

t1.normalize();

return ins;
}
ostream& operator <<(ostream& out, Time& t1)
{
if(t1.hours < 10)
out << '0' << t1.hours << ":";
else
out << t1.hours << ":";
if(t1.minutes < 10)
out << '0' << t1.minutes << ":";
else
out << t1.minutes << ":";
if(t1.seconds < 10)
out << '0' << t1.seconds;
else
out << t1.seconds;

return out;
}

int main()
{
Time t1, t2, t3, t4;
cin >> t1;
cin >> t2;
cin >> t3;

cout << "Time1: " << t1 << endl;
cout << "Time2: " << t2 << endl;
cout << "Time3: " << t3 << endl;

t4 = t1 + t2;
cout << "Time4: " << t4 << endl;

t1 = t3 - t4;
cout << "Time1: " << t1 << endl;

if (t1 < t3)
cout << "Time1 < Time3" << endl;
else
cout << "Time3 >= Time1" << endl;

Time t5 = t2 + Time(0,0,1);
if (t5 < t2)
cout << "Time5 < Time2" << endl;
else
cout << "Time5 >= Time2" << endl;

cout << "Almost midnight: " << Time(0,0,0) - Time(0,0,1) << endl;

return 0;
}

Time operator + (const Time& t1, const Time& t2)
{
Time temp;
temp.hours = t1.hours + t2.hours;
temp.minutes = t1.minutes + t2.minutes;
temp.seconds = t1.seconds + t2.seconds;

return temp;
}

Time operator - (const Time& t1, const Time& t2)
{
Time temp;

temp.hours = t1.hours - t2.hours;
temp.minutes = t1.minutes - t2.minutes;
temp.seconds = t1.seconds - t2.seconds;

temp.normalize();

return temp;
}

bool operator < (const Time& t1, const Time& t2)
{
if(t1.hours < t2.hours && t1.minutes < t2.minutes && t1.seconds < t2.seconds)
return true;
else
return false;
}



First I got many errors in my code, I've fixed a few. Now I have this one and I can't seem to figure it out.

error: no match for 'operator<<' in 'std::operator<< <std::char_traits<char> >((* & std::cout), ((const char*)"Almost midnight: ")) << operator-((*(const Time*)(& Time(0, 0, 0))), (*(const Time*)(& Time(0, 0, 1))))'|

Can anyone help me with this assignment? or tell me what I'm doing wrong?
Topic archived. No new replies allowed.