c 结构体 函数 指针

#include "stdio.h"
struct DEMO
{
int x,y;
int (*func)(int,int); //函数指针
};
int add2(int x,int y)
{
return x+y;
}
void main()
{
struct DEMO demo;
demo.func
=&add2; //结构体函数指针赋值
printf("func(3,4)=%d\n",demo.func(3,4));
}

posted @ 2011-07-11 18:14  wangkangluo1  阅读(289)  评论(0编辑  收藏  举报