#include<iostream>
using std::cout;
using std::endl;
int Sum(int a,int b)
{
return a+b;
}
void Show(int (*ptr_sum)(int,int))
{
cout<<"Show:"<<ptr_sum(1,2)<<endl;
}
int main()
{
//函数指针
int (*ptr_sum)(int,int);
ptr_sum = Sum;
cout<<"Sum:"<<ptr_sum(1,2)<<endl;
Show(ptr_sum);//函数指针做实参
system("pause");
return 0;
}
using std::cout;
using std::endl;
int Sum(int a,int b)
{
return a+b;
}
void Show(int (*ptr_sum)(int,int))
{
cout<<"Show:"<<ptr_sum(1,2)<<endl;
}
int main()
{
//函数指针
int (*ptr_sum)(int,int);
ptr_sum = Sum;
cout<<"Sum:"<<ptr_sum(1,2)<<endl;
Show(ptr_sum);//函数指针做实参
system("pause");
return 0;
}