首页 > 编程语言 > 详细

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

时间:2019-09-21 23:23:54      阅读:148      评论:0      收藏:0      [点我收藏+]

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

 

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

原文:https://www.cnblogs.com/dlvguo/p/11565249.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!