标签:函数 blog init zhang include color class nbsp code
结构体内嵌函数指针
#include<stdio.h> void say(int age) { printf("我%d岁了\n",age); } struct student { int age; char name[10]; int isman; void (*say)(int age); }; void init(struct student *app) { app->say=say; } void main() { struct student zhangsan; init(&zhangsan); zhangsan.age=10; zhangsan.isman=1; zhangsan.say(zhangsan.age); }
标签:函数 blog init zhang include color class nbsp code
原文地址:http://www.cnblogs.com/PengfeiSong/p/6161001.html