错误:调用'(Time)(int,int,int)'不匹配

时间:2013-07-29 22:14:56

标签: c++ compiler-errors

我正在学习C ++,并且我正在尝试使用未包含在dev c ++中的头文件来完成练习。我已经尝试导入头文件,dev c ++显示它被列为标题。另外,我创建了一个项目,并在编译之前将ccc_time.h文件添加到项目中,然后根据这个常见问题进行编译。这就是我所做的:

#include <iostream>

using namespace std;

#include "ccc_time.h"

int main()

{
    Time wake_up;

    wake_up (7, 7, 7);
    wake_up.add_seconds(1000);
    cout << wake_up.get_hours()
        << ":" << wake_up.get_minutes()
        << ":" << wake_up.get_seconds() << "\n";

    Time now;
    int seconds_left = Time(23, 59, 59).seconds_from(now);

    cout << "There are "
    << seconds_left
    << " seconds left in this day.\n";

    return 0;
}

我得到的错误是:

[Error] no match for call to '(Time) (int, int, int)'

我错过了什么?

1 个答案:

答案 0 :(得分:2)

如果你正在调用构造函数Time(int, int, int),你应该这样做:

Time wake_up (7, 7, 7);

如果不是Time应该有operator(int, int, int)

编辑:您可以按如下方式定义operator(int, int, int)

void Time::operator(int a, int b, int c)
{
  // do something appropriate
}
相关问题