头文件
#pragma once
#include <iostream>
using namespace std;
typedef int(FUNCPTRPA)(int rIndex);
typedef struct
{
int a;
int b;
}TEST1;
typedef struct
{
FUNCPTRPA*fun_send;
FUNCPTRPA*fun_reve;
int yx;
int yc;
union
{
TEST1 test1;
}test;
}TEST;
int syw_test_send(int rindex);
int syw_test_reve(int rindex);
class StructUnion
{
public:
StructUnion(void);
~StructUnion(void);
TEST test2;
};
.cpp
#include "StructUnion.h"
StructUnion::StructUnion(void)
{
}
StructUnion::~StructUnion(void)
{
}
int syw_test_send( int rindex )
{
cout<<rindex<<endl;
return rindex;
}
int syw_test_reve( int rindex )
{
cout<<rindex<<endl;
return rindex;
}
void main()
{
TEST Test[3];
int i =2;
Test[i].fun_reve = syw_test_reve;
Test[i].fun_send = syw_test_send;
Test[i].fun_send(111);
StructUnion su;
su.test2.fun_reve = syw_test_reve;
su.test2.fun_reve(111);
system("pause");
}