#include <stdio.h>
typedef int func(int a , int b);
struct test_struct {
int x;
int y;
func * pfunc;
};
int add(int a , int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
void main()
{
struct test_struct * p_test_struct , test_struct_1;
test_struct_1.x = 10;
test_struct_1.y = 10;
test_struct_1.pfunc = add;
p_test_struct = & test_struct_1;
int z = p_test_struct->pfunc(20,10);
printf("%d\n",z);
test_struct_1.pfunc = sub;
z = p_test_struct->pfunc(20,10);
printf("%d\n",z);
}
typedef int func(int a , int b);
struct test_struct {
int x;
int y;
func * pfunc;
};
int add(int a , int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
void main()
{
struct test_struct * p_test_struct , test_struct_1;
test_struct_1.x = 10;
test_struct_1.y = 10;
test_struct_1.pfunc = add;
p_test_struct = & test_struct_1;
int z = p_test_struct->pfunc(20,10);
printf("%d\n",z);
test_struct_1.pfunc = sub;
z = p_test_struct->pfunc(20,10);
printf("%d\n",z);
}