2016-03-29 4 views
0
を呼び出す機能がありません

私はC++で新しく、メインクラスからBMクラスメソッドを呼び出すスレッドを利用したいと思います。main.cpp、BM.h、BM.cppファイルがありますスレッドC++:

main.cppにで私のコードの一部

string id = res->getString("nct_id"); 
char txt[temp_size]; 
char pat[5]; 
BM bm ; 
thread Sam(&BM::search,&bm, txt, pat ,id); // use thread calls class method 

BM.h

void search(char *txt, char *pat , string id); 

BM.cpp

void BM::search(char *txt, char *pat ,string id) 

私はエラーがあります:

No matching function for call to 
'std::thread::thread(void (BM::*)(char*, char*, std::string), BM*, char [(((sizetype)(((ssizetype)temp_size) + -1)) + 1)], char [5], std::string&)' 

あなたは非標準の言語拡張を使用しているので、これはあなたに

+0

を 'txt'、' pat'と 'id'の宣言を提供します。 – Zereges

答えて

2

に感謝助けてください、すなわち、可変長配列(のVLA)。これらの配列はテンプレートではうまく機能しません。すべての文字配列とすべてのVLAを削除し、std:stringとstd :: vectorを使用することをお勧めします。

あなたは、この単純な回避策を使用できない場合:

thread Sam(&BM::search,&bm, &txt[0], pat ,id);