1.函數(shù)指針,類似于iOS的代碼塊block瑰谜,將一段代碼注入到方法中醉锅,在代碼中執(zhí)行
#include <iostream>
using namespace std;
void testInt(int a){
cout<<"i am in the method";
}
void testTheMethod(void(*method)(int a)){
cout<<"i am in the right place";
method(4);
}
int main(){
void(*method)(int a)=NULL;
method=&testInt;
testTheMethod(method);
return0;
}
2.泛型定義
template <typename T>