int (*p)(int a, int b); //p是一个指向函数的指针变量,所指函数的返回值类型为整型
int *p(int a, int b); //p是函数名,此函数的返回值类型为整型指针
int fn1(int x, int y); int fn2(int x);
int (*p1)(int a, int b); int (*p2)(int a);
p1 = fn1; //正确 p2 = fn2; //正确 p1 = fn2; //产生编译错误
// MethodPoint.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
typedef int (*pf)(const int& a,const int& b);
int sum(const int& a,const int& b){
return a + b;
}
int minus(const int& a,const int& b){
return a - b;
}
int doSometing(const int& a,const int& b, pf p){
return p(a, b);
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << doSometing(1, 2, &sum) << endl;
cout << doSometing(1, 2, &minus) << endl;
system("pause");
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有