码迷,mamicode.com
首页 > 编程语言 > 详细

c / c++ 结构体的定义与使用

时间:2015-02-06 15:02:16      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

头文件

#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");
}


c / c++ 结构体的定义与使用

标签:

原文地址:http://blog.csdn.net/u010236550/article/details/43563305

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!