#pragma once/**//*Super_Super.h*//**//*僋儔僗偺掕媊*/typedef struct CSuper_Super_t...{ /**//*僒僽乕僋儔僗偺僀儞僗僞儞僗*/ void * body; /**//*帺恎偺僋儔僗曄悢*/ int Value;}CSuper_Super;extern int Super_Super_GetValue(CSuper_Super*); /**//*Super_Super.c*/#include "Super_Super.h"/**//*僋儔僗娭悢*/int Super_Super_GetValue(CSuper_Super* this)...{ return this->Value;} #pragma once/**//*Super.h*/#include "Super_Super.h"/**//*僋儔僗偺掕媊*/typedef struct CSuper_t...{ CSuper_Super super; /**//*僒僽乕僋儔僗偺僀儞僗僞儞僗*/ void * body; }CSuper;/**//*弶婜壔曄悢*/extern void Sub_Initialize(CSuper*);/**//*儅僋儘偺掕媊*/#define Super_GetValue(p) Super_Super_GetValue(p) /**//*Super.c*/#include "Super.h"#include "Super_Super.h"/**//*弶婜壔娭悢*/void Super_Initialize(CSuper* this)...{ this->super.body = this;} /**//*Sub.h*/#pragma once#include "super.h"#include "super_super.h"/**//*僋儔僗偺掕媊*/typedef struct CSub_t...{ CSuper super;}CSub;extern void Sub_Initialize(CSub*);#define Sub_GetValue(p) Super_GetValue(p); /**//*Sub.c*/#include "sub.h"void Sub_Initialize(CSub* this)...{ this->super.body = this;} /**//*main.c*/#include "sub.h"#include "super.h"#include "super_super.h"CSub mSub;CSub *pSub;void main()...{ int ret1 = 0; /**//*億僀儞僞偺弶婜壔*/ pSub = &mSub; Sub_Initialize(pSub); Super_Initialize(pSub); ret1 = Sub_GetValue(pSub); ret1 = Super_GetValue(pSub); ret1 = Super_Super_GetValue(pSub); } 多层继承的主旨是子类能用父类公共的方法 这个就是通过宏来实现的。 在初期化的时候一定要初期化CSuper super才可以。 父类的部分有了实体,宏才可以用。