#include <iostream>
using namespace std;
int power(int num1,int num2 ) {
return num1 + num2;
}
int main() {//函数指针
int(*ptrPower)(int,int);//函数指针声明
ptrPower = power;//函数指针ptrPower指向power函数
cout << power(3,3) << endl;//直接调用
cout <<ptrPower(3,3) << endl;//通过函数指针调用
cout << (*ptrPower)(3, 3) << endl;//通过函数指针调用
return 0;
}
函数指针

最新推荐文章于 2025-05-12 19:30:31 发布