
/**//*Super.h*/
typedef void (*get)(void*,short);
typedef void (*set)(void*,short);
typedef void (*clear)(void*,short);


typedef struct CSuper_t...{
void * body;
get Get;
set Set;
clear Clear;
}CSuper;

/**//*Sub.h*/
#include "Super.h"


typedef struct CSub_t...{
CSuper super;
void* body;
get Get;
set Set;
clear Clear;
short member;
}CSub;

/**//*SubRealize.c*/
#include "SubRealize.h"

CSub* CSubRealize_Initial(CSubRealize* this)

...{
this->super.Get=CSubRealize_Get;
this->super.Set=CSubRealize_Set;
this->super.Clear=CSubRealize_Clear;
return &(this->super);
}
void CSubRealize_Get(CSubRealize* this,short id)

...{
this->super.member=id;
}
void CSubRealize_Set(CSubRealize* this,short id)

...{
this->super.member=2*id;
}
void CSubRealize_Clear(CSubRealize* this,short id)

...{
this->super.member=0;
}

/**//*SubRealize.h*/
#include "Sub.h"

typedef struct CSubRealize_t...{
CSub super;
}CSubRealize;
extern void CSubRealize_Get(CSubRealize* this,short id);
extern void CSubRealize_Set(CSubRealize* this,short id);
extern void CSubRealize_Clear(CSubRealize* this,short id);
extern CSub* CSubRealize_Initial(CSubRealize* this);
关键还是要看到,要给在父类的函数指针付值,还有给初始化函数加返回值总觉得不是很好。所以就改了下
不过把super暴露在外面了
#include "subrealize.h"
CSubRealize subrealize;
CSub* pSub;
short id=10;
void main()

...{
pSub=CSubRealize_Initial(&subrealize);
#if 0
(pSub->Get)(&subrealize,id);
(pSub->Set)(&subrealize,id);
(pSub->Clear)(&subrealize,id);
#endif
subrealize.super.Get(&subrealize,id);
subrealize.super.Set(&subrealize,id);
subrealize.super.Clear(&subrealize,id);
}