这是完整的错误信息:
错误:无法将参数 '1' 的 'MyTime' 转换为 'const MyTime*' 到 'int determineElapsedTime(const MyTime*, const MyTime*)'|
这是我的代码:
#include <iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
struct MyTime { int hours, minutes, seconds; };
int DetermineElapsedTime(const MyTime *t1, const MyTime *t2);
const int hourSeconds = 3600;
const int minSeconds = 60;
int DetermineElapsedTime(const MyTime *t1, const MyTime *t2)
{
long timeDiff = ((((t2->hours * hourSeconds) + (t2->minutes * minSeconds) + t2->seconds) -
((t1->hours * hourSeconds) + (t1->minutes * minSeconds) + t1->seconds)));
return(timeDiff);
}
int 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;
DetermineElapsedTime(tm, tm2);
return 0;
}
有什么办法可以解决吗?请随时指出您看到的任何其他错误。我确实知道修复确定时间以正确输出 hr:min:sec 格式。但现在我需要克服这个。