首页 > 编程语言 > 详细

【c++程序】函数指针

时间:2015-04-21 18:05:37      阅读:141      评论:0      收藏:0      [点我收藏+]
#include<iostream>
using namespace std;
#include<cstring>
void reset(int a[],int n);
void input(int a[],int n);
void output(int a[],int n);
void sort(int a[],int n);
int main()
{
	void (*fp)(int a[],int n)=NULL;//相应的函数指针
	int x[5];
	fp=output;
	output(x,5);
	fp(x,5);
	fp=reset;
	fp(x,5);
	fp=output;
	fp(x,5);
}
void reset(int a[],int n)
{
	memset(a,0,sizeof(int)*n);//设置内存中数据
	/*for(int i=0;i<n;i++)
		a[i]=0;*/
}
void output(int a[],int n)
{
	for(int i=0;i<n;i++)
		cout<<a[i]<<' ';
	cout<<endl;
}

【c++程序】函数指针

原文:http://blog.csdn.net/u012503639/article/details/45172793

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!