Created
May 17, 2015 09:11
-
-
Save CedricGuillemet/6e795ccd09affdf5de77 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
class A | |
{ | |
public: | |
void method(int a, int b) const | |
{ | |
printf("0x%x %d - %d \n", this, a, b); | |
} | |
}; | |
class B | |
{ | |
public: | |
void method(float a) | |
{ | |
mExp = a*10.f; | |
printf("0x%x %f \n", mExp); | |
} | |
float mExp; | |
}; | |
#define MakeFunc(x,y) | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
A objA; | |
B objB; | |
std::vector< std::function< void() > > vec; | |
int a = 10, b = 20; | |
std::function< void() > callback = [objA, a, b]() { objA.method(a, b); }; | |
vec.push_back(callback); | |
float c = 5.f; | |
std::function< void() > callback2 = [objB, c]() { objB.method(c); }; | |
vec.push_back(callback2); | |
vec[0](); | |
vec[1](); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment