6.3w+
社区成员
#include <iostream>
using namespace std;
void (*pfun(int a))(int b) // 以这种形式定义的,不想要返回值怎么写?
{
cout<<"pfun: "<<a<<endl;
return 0;
}
//int b 要怎么用上,还有这么用函数指针形式和普通的函数定义有什么区别?
void fun() //普通函数定义
{
}
int main()
{
pfun(9);
return 0;
}
pfun是一个返回函数指针的函数
#include <iostream>
using namespace std;
void fun(int c) //普通函数定义
{
cout << c << "fun" << endl;
}
void (*pfun(int a))(int b) // 以这种形式定义的,不想要返回值怎么写?
{
cout<<"pfun: "<<a<<endl;
return &fun;
}
//int b 要怎么用上,还有这么用函数指针形式和普通的函数定义有什么区别?
int main()
{
(*pfun(9))(10);
return 0;
}