结构体成员的特殊访问方法

// 结构体中的元素的第二种访问的方法。
#include <stdio.h>
#include <stdlib.h>
struct Person{

int age;

void (*p)();
};

void persons(){

printf("have lunch\n ");
}
int main(){

//这里是特殊的访问的方法需要时刻的注意,这里可以是实现对结构体的特定的对象进行赋值
struct Person person={

.age=89,
.p=persons

};

 

person.p();

return 0;
}
~
~

posted @ 2021-03-16 11:11  LInguistic-零点  阅读(187)  评论(0编辑  收藏  举报