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);
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM