Original Post
I've been trying to get an exercise in my book to work but I keep recieving a error. Even though my source is almost identical to the answer in the back of the book with the exception of different var names. C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion) The problem i'm working from is in the Sams Robert Lafore book, Object Oriented Programming Version 4, Chapter 6 Exercise 3. Create a class called time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to fixed values. Another member function should display it, in 11:59:59 format. The final member function should add two objects of type time passed as arguments. //------------------------------------------------------------- My Code //------------------------------------------------------------- #include #include //-------------------------------------------------------- class time { private: int hours, minutes, seconds; public: time() : hours(0), minutes(0), seconds(0) {} time(int h, int min, int sec) : hours(h), minutes(min), seconds(sec) {} void display() { cout << "Time: " << hours << ":" << minutes << ":" << seconds; } void add_time(time a, time b) { seconds=a.seconds+b.seconds; minutes=a.minutes+b.minutes; hours=a.hours+b.hours; if(seconds> 59) { minutes++; seconds-=60; } if(minutes> 59) { hours++; minutes-=60; } } }; //-------------------------------------------------------- void main() { time a(1,1,50); time b(2,59,40); time c; c.add_time(a, b); cout << "time c = " << c.display(); cout << endl; getch(); } //---------------------------------------------------------