aaa.c

来自「用C实现虚函数表的例子」· C语言 代码 · 共 52 行

C
52
字号
// StringManager.cpp: implementation of the CStringManager class.
//
//////////////////////////////////////////////////////////////////////

#include "aaa.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IAAA* AAA_New()
{
	IAAA * pMe = NULL;

	VTBL(IBBB) *modFuncs;

	// Allocate memory for the ExtensionCls object
	if( (pMe =(IAAA *)MALLOC(sizeof(AAA) + sizeof(IBBBVtbl))) == NULL )
		return NULL;

	//pMe->pAaa = TEST_New(); 
	// Allocate the vtbl and initialize it. Note that the modules and apps must not
	// have any static data. Hence, we need to allocate the vtbl as well.
	modFuncs = (IBBBVtbl *)((byte *)pMe + sizeof(BBB));
	//Initialize individual entries in the VTBL

	modFuncs->Refresh	= BBB_Refresh;
	modFuncs->aa		= BBB_aa;
	modFuncs->bb		= BBB_bb;
	modFuncs->cc		= BBB_cc;
	modFuncs->ww		= BBB_ww;
	modFuncs->DD		= AAA_DD;

	// initialize the vtable
	INIT_VTBL(pMe, IBBB, *modFuncs); 

	// initialize the data members

	DBGPRINTF("TEST_AAAAAAAAAAAAAAAAAAA");

	return (IAAA *)pMe;
}


void AAA_DD(IAAA *po)
{
	AAA *pMe = (AAA *)po;
	DBGPRINTF("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
	pMe->tt = 88;
	DBGPRINTF("%d**************************************",pMe->tt);
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?