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