/* g++ -g struct.cpp -o struct */ #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct bus_od{ int a; int func(){ int b = a + 1; return b; }; } BUS_OD; int main() { BUS_OD *new_p_bus_od = (BUS_OD *)malloc(sizeof(BUS_OD)); new_p_bus_od->a = 3; int c = new_p_bus_od->func(); printf("c=%d\n",c); return 0; }