I was writing a simple program which I have to overload the << operator so as to display the class object using cout instead of to a use a method for that.
1 2 3 4 5 6
voidoperator<<(std::ostream &os, Time &t); // prototype within a header.h
//function definition in time.cpp
void Time::operator<<(std::ostream &s, Time &t)
s << t.hours << " hours " << t.minutes << " minutes << std::endl;
But the compiler keeps telling that error: 'void Time::operator<<(std::ostream&, const Time&)' must take exactly one argument|. I don't know what I was doing wrong. Please someone should point me out. Thanks