0
g ++での機能の使用に問題があります。私は!g++ -o test test.cpp -std=c++11
でコンパイルしてもエラーはなく、プログラムもうまく動作します。私は、コンパイルする前にSyntasticを使用してエラーをチェックし、次のような出力が得られます。g ++には関数ライブラリが含まれていますか?
これは私のプログラムTEST.CPPです:
1 #include <functional>
2
3 using namespace std;
4
5 int f(int x){
6 return x;
7 }
8
9 void f2(function<int(int)> f){
10
11 }
12
13 int main(){
14 return 0;
15 }
エラーは次のとおりです。
1 test.cpp|9 col 9 error| variable or field ‘f2’ declared void
2 test.cpp|9 col 9 error| ‘function’ was not declared in this scope
3 test.cpp|9 col 18 error| expected primary-expression before ‘int’
このエラーは何を意味し、私はそれをどのように修正するのですか?