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

 

相关文章:

  • 2021-12-12
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-04-13
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2019-03-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-12-14
  • 2022-12-23
  • 2021-05-26
相关资源
相似解决方案