vtable layout and lookup

struct cA ;

struct A_vtbl
{
void (__stdcall* pfn_mem_fun)( struct cA* this, int v ) ;
void (__stdcall* pfn_mem_fun2)( const struct cA* this ) ;
void (__stdcall* pfn_mem_fun3)( struct cA* this ) ;
void (__stdcall* pfn_destructor)( struct cA* this ) ;
};

struct cA
{
struct A_vtbl* vptr ;
char c1 ;
int i ;
char c2[1] ;
};

void cfun( struct cA* pa )
{
//pa->mem_fun2() ;
pa->vptr->pfn_mem_fun2(pa) ;
//pa->mem_fun(100) ;
pa->vptr->pfn_mem_fun(pa,100);
}

Popular posts from this blog

OpenLayers Advanced Clustering and Setting dynamic images for OpenLayer Styles via Ajax

Long running Java process resource consumption monitoring , leak detection and GC tuning

Compiling OpenCV with CUDA (GPU) using CMake (GUI)