0
Help me in c++
how can i fix the error #include <iostream> using namespace std; struct time{ int hour, minute, second; }; time computeTimeDifference(time t1, time t2){ return t1 - t2; } int main(){ time TIMEDIFFERENCE, T1, T2; cout << "Enter hours, minutes and seconds respectively:\n"; cin>> T1.hour >> T1.minute >>T1.second; cout <<"Enter stop time"; cout << "Enter hours, minutes and seconds respectively:\n"; cin>> T2.hour >> T2.minute >>T2.second; TIMEDIFFERENCE computeTimeDifference(T1, T2);
6 Answers
+ 2
What do you expect from t1-t2 statement inside computeTimeDifference function? And you think that compiler know that?
+ 1
Then, time is a name of a function which iostream include... Use another name... Futhermore you defined a structure and you expect that compiler know how do subtraction between 2 objects of this struct and is not true. You have to define a function that do the subtraction and return it
+ 1
You are welcome.. Anyway i suggest 2 things: first, read always compiler error output and second, when post some code here, use code bits so is more easy help
0
this is the rest of the code
cout<<"TIME DIFFERENCE:" <<T1.hour<<":"<<T1.minute<<":"<<T1.second;
cout << " - " << T2.hour<<":"<<T2.minute <<":"<<T2.second;
cout << " = "<< TIMEDIFFERENCE.hour <<":" <<TIMEDIFFERENCE.minute <<":"<<TIMEDIFFERENCE.second;
return 0;
}
0
where should i put it ?
0
ok thank you