Missmiaom
5/7/2020 - 9:11 AM

functional

C-Style

void fun(int a) {} 
  
int main() 
{ 
    // fun_ptr is a pointer to function fun()  
    void (*fun_ptr)(int) = &fun; 
  
    /* The above line is equivalent of following two 
       void (*fun_ptr)(int); 
       fun_ptr = &fun;  
    */
  
    // Invoking fun() using fun_ptr 
    (*fun_ptr)(10); 
  
    // type of fun_ptr is void (*)(int)
    return 0; 
} 

C++11

std::function<void(void)> f = std::bind(&Foo::doSomething, this);