2

私は 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)'

私は何が欠けていますか?

4

1 に答える 1

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
}
于 2013-07-30T01:33:10.810 に答える