Bind is not a member of std

I am using netbeans 7.2.1 with the minwg compiler. When I try to create an application, I get the following error messages:

error: 'function' in namespace 'std' does not name type

error: 'bind' is not a member of 'std'

although I included the .h functionality at the beginning of the file, and I use 'function' and 'bind' in the form: std :: function and std :: bind

Where is the problem? Is it in the compiler or is something missing? I remember that I compiled and ran the same application on visual studio 2010.

+7
source share
3 answers

It is not functional.h , it is just functional .

 #include <functional> //without .h 

Note that std::function and std::bind only ship with C ++ 11. Therefore, you may need to update your compiler if you have not already done so.

Alternatively, compile your code with the -std=c++11 option:

 $ g++ -std=c++11 file.cpp 

This should work if you updated your compiler. If your compiler is a bit outdated, you can also try -std=c++0x .

+11
source

You need to include the functional header. It is available in C ++ 11 . If you still have problems, your compiler may not support C ++ 11. Try updating.

+5
source

You can also use boost :: bind:

 #include <boost/bind.hpp> 
0
source

All Articles