Last active
January 29, 2017 04:31
-
-
Save keisukeYamagishi/b7fa11d131acb8b04eef967011e0ab6d 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> | |
////////////////////////// | |
// call back variable | |
////////////////////////// | |
typedef std::function<void(int num, char* ch)> func; | |
typedef std::function<void(int num, char* ch, int num2)> func2; | |
void callSecond(int num, char* ch, const func2& f2){ | |
std::cout << "call callSecond !!!" << std::endl; | |
f2(num,ch,10); | |
} | |
void call(int num, char* c, func f){ | |
std::cout << "call back dude!!" << std::endl; | |
f(num, c); | |
} | |
////////////////////////// | |
// call back function | |
////////////////////////// | |
void function_back(int num, char* ch){ | |
std::cout << "num variable :: " << num << "char* ch :: >> " << ch << std::endl; | |
} | |
int main(){ | |
std::function<void(int num, char* ch)> call_back; | |
call_back = function_back; | |
call_back(1, " yamada death "); | |
call(20, "call back",[=](int num, char* c){std::cout << num << c << std::endl;}); | |
callSecond(20, "konyaga_yamada" ,[=](int num, char* ch,int num2){std::cout << num << ch << std::endl;}); | |
return 0; | |
} |
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> | |
////////////////////////////////////// | |
// call back function | |
// | |
////////////////////////////////////// | |
void function_back(int num, char* ch){ | |
std::cout << "num variable :: " << num << "char* ch :: >> " << ch << std::endl; | |
} | |
int main(){ | |
std::function<void(int num, char* ch)> call_back; | |
call_back = function_back; | |
std::function<void(int num, char* ch)> call_b; | |
call_b = [=](int num, char* ch){printf("char :: %s\nnum :: %d",num, ch );}; | |
call_back(1, " yamada death "); | |
return 0; | |
} |
compile:
c++ -std=c++11 c_b.cpp -o c_b
compile:
c++ -std=c++11 cp2.cpp -o cp2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ramda C++ study
c++