c++传递函数当作对象传递

c++中函数当作对象来传递,类似c#中的指针操作如:

#include <iostream>
using namespace std;

int tst(int a){
    cout<<a<<endl;
    return 5;
}

//类型 +(* +变量名)(+ 函数需要参数)
void BigTest(int (* test)(int a)){
    int c= test(5);
}

int main()
{   
    //传递进来一样的函数
    BigTest(tst);
}

猜你喜欢

转载自www.cnblogs.com/dlvguo/p/11565249.html