Last active
December 21, 2015 10:18
-
-
Save yasuharu519/213307b4709662e60df2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
#include <string> | |
class Foo | |
{ | |
public: | |
Foo(std::function<int(std::string, std::string, std::string)> fFunction) : fnCallback{fFunction} {} | |
int Call() { return fnCallback("first", "second", "third"); } | |
protected: | |
std::function<int(std::string, std::string, std::string)> fnCallback; | |
}; | |
class Bar | |
{ | |
public: | |
static int Function(std::string s1, std::string s2, std::string s3) | |
{ | |
std::cout << s1 << s2 << s3 << std::endl; | |
return 0; | |
} | |
}; | |
int main(int /*nArgc*/, char* /*paszArgv*/ []) | |
{ | |
using namespace std::placeholders; | |
auto fn = std::bind(Bar::Function, _1, _2, _3); | |
Foo oFoo(fn); | |
oFoo.Call(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment