Function of Boost library

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.