
下面以一个例子来说明(为了方便,结构体命名方面就马虎点了):
#ifndef _STRUCTTEST_H_
#define _STRUCTTEST_H_
typedef struct tag_Base
{
int s32Count;
char byNone;
bool bYes;
long dwTemp;
tag_Base()
{
s32Count = 100;
byNone = 'Y';
bYes = true;
dwTemp = 200;
printf("Base created!\n");
};
}TBase;
typedef struct tag_Base2
{
int s32Count;
char byNone;
long dwTemp;
bool bYes;
tag_Base2()
{
s32Count = 100;
byNone = 'Y';
bYes = true;
dwTemp = 200;
printf("Base2 created!\n");
};
}TBase2;
typedef struct tag_InheritBase : public TBase
{
char byIyes;
int dwItemp;
tag_InheritBase()
{
byIyes = '0';
dwItemp = 1023;
printf("Tinherit has been created!