#include <iostream> struct student { int a; int b; int add(){ //在结构体内封装了函数 return a+b; } }; int main(){ student s={10,20}; //c++时struct 可以省略
int x=s.add(); printf("%d\n",x); }