|55|error: no match for 'operator<<' in 'std::cout << DetermineElapsedTime(((const MyTime*)(& tm)), ((const MyTime*)(& tm2)))'|
I realize that cout does not understand the how to output that correctly. However, at this moment neither do I.
Here is my code. The issue is all the way near the bottom.
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
struct MyTime { int hours, minutes, seconds; };
MyTime DetermineElapsedTime(const MyTime *t1, const MyTime *t2);
const int hourSeconds = 3600;
const int minSeconds = 60;
const int dayHours = 24;
MyTime DetermineElapsedTime(const MyTime *t1, const MyTime *t2)
{
long hourDiff = ((t2->hours * hourSeconds) - (t1->hours * hourSeconds));
int timeHour = hourDiff / hourSeconds;
long minDiff = ((t2->minutes * minSeconds) - (t1->minutes * minSeconds));
int timeMin = minDiff / minSeconds;
int timeSec = (t2->seconds - t1 -> seconds);
MyTime time;
time.hours = timeHour;
time.minutes = timeMin;
time.seconds = timeSec;
return time;
}
main(void)
{
char delim1, delim2;
MyTime tm, tm2;
cout << "Input two formats for the time. Separate each with a space. Ex: hr:min:sec\n";
cin >> tm.hours >> delim1 >> tm.minutes >> delim2 >> tm.seconds;
cin >> tm2.hours >> delim1 >> tm2.minutes >> delim2 >> tm2.seconds;
if (tm2.hours <= tm.hours && tm2.minutes <= tm.minutes && tm2.seconds <= tm.seconds)
{
tm2.hours += dayHours;
}
cout << DetermineElapsedTime(&tm, &tm2); // Problem is here
return 0;
}
Also, any hints on how I can output the time elapse as 01:01:01 if needed? I know about setfill.. somewhat.
MyTime is a struct. Overload the << operator for this type