2016-05-07 19 views
0

printReportとaddToCatalogVariableeは、両方の別々のヘッダおよびクラスファイルで定義した、マルチスレッドのVisual Studio C++

std::thread thread_1(addToCatalogVariablee(stage_completion, m_load_profiles, m_load_stable_instances, m_load_instance_round, m_load_instance_struct)); 

std::thread thread_2(printReport(m_load_stable_instances, m_file_name_in)); 

を私は、Visual Studioを使用していて、次のスレッドの例では、エラーを発生させます。しかし、Visual Studioのフラグ

エラー、のように両方のライン:コンストラクタのインスタンスが引数リストに一致しない 引数の型は次のとおりです。(無効)

+1

http://stackoverflow.com/help/mcve –

+0

あなたはマニュアル読めばそれが良いでしょう。 http://en.cppreference.com/w/cpp/thread/thread/thread – AnatolyS

答えて

0

私は野生の推測を取るつもりです:あなたにはprintReportを呼び出したいです2つのメンバ変数を引数として渡します。これは、サンプルコードでやっていることではありません。このスレッドの関数を呼び出して、を呼び出し、その関数の結果をstd::threadのコンストラクタに渡します。

printReportの場合は、何が必要だけで、通常の関数、または静的メンバ関数です:

std::thread thread_2(printReport, m_load_stable_instances, m_file_name_in); 

printReportは、このクラスの非静的メンバ関数であれば、あなたが必要となります。

std::thread thread_2(&ThisClass::PrintReport, this, 
         m_load_stable_instances, m_file_name_in);