FirstTest.cpp: Defines the entry point of the console application. Function<type> the address of the storage method, the wrapper (function wrapper)//*iterator1 content for the parameter is passed in Function#include "stdafx.h" #include < boost/function.hpp> #include <string> #include <iostream> using namespace std;using namespace boost; Class Funtest{private:string M_name;public:funtest (string name) {m_name = name;} void Print_mem (String elem) {cout << elem << this->m_name << Endl;}}; void Printelem (String &elem) {cout << elem <<endl;} int main () {///normal method uses string name = "Leeboy"; boost::function<void (String &) > Fun;fun = &printelem;fun ( name);//The funtest* is stated here because all member methods implicitly pass the this pointer//to the pointer to the class to indicate the point of this boost::function<void (funtest*, String) > Funclass;funclass = &funtest::p rint_mem; Funtest Test ("Leeboy"); Funclass (&test, "Hello"); System ("pause"); return 0; }
Function of Boost library