Skip to content

Instantly share code, notes, and snippets.

@keisukeYamagishi
Created January 20, 2017 14:53
Show Gist options
  • Save keisukeYamagishi/348d434db0b93b10c2773f5be8acf2c2 to your computer and use it in GitHub Desktop.
Save keisukeYamagishi/348d434db0b93b10c2773f5be8acf2c2 to your computer and use it in GitHub Desktop.
#include <iostream>
#include "stu.h"
int main() {
char* ch = "Call";
name1::name2::name3::stu::getInstance()->call(10,ch, [=](int num, char* ch){
printf("num ++ >> %d char ** > %s",num,ch);
});
return 0;
}
#include "stu.h"
#include <iostream>
namespace name1{
namespace name2{
namespace name3{
static stu* stu1 = NULL;
stu * stu::getInstance() {
if(stu1==NULL){
stu1 = new stu;
}
return stu1;
}
void stu::call(int num, const char *ch, const CallBackFunction &call){
std::cout << "num >> " << num << "char :: > " << ch << std::endl;
}
}
}
}
//
// Created by shichimi on 2016/12/05.
//
#ifndef STUDY_STU_H
#define STUDY_STU_H
#include <functional>
namespace name1{
namespace name2{
namespace name3{
class stu {
public:
static stu * getInstance();
typedef std::function<void(int num, char* ch)> CallBackFunction;
void call(int num, const char *ch, const CallBackFunction &call);
};
}
}
}
#endif //STUDY_STU_H
@keisukeYamagishi
Copy link
Author

C++ study

@keisukeYamagishi
Copy link
Author

compile:

 c++ -std=c++11 main.cpp stu.cpp -o stu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment