Use a friend function to overload the >> operator
class Time
{
private:
int hour, minute, second;
public:
Time() {hour = mijnute = second = 0;}
friend istream& operator >> (istream& in, Time& t);
};
// Put this in the *.cpp file, not the *.h file
istream& operator >> (istream& in, Time& t)
{
cout << "Enter time";
cin >> t.hour >> t.minute >> t.second;
return in;
};
Last edited by Ancient Dragon; Oct 26th, 2009 at 12:48 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Offline 21,953 posts
since Aug 2005