sizeof…
Posted by kiraninbng on July 5, 2006
Here is a simple way to find the size of an object without using the sizeof operator,
class CTest { … }
CTest oCTest;
CTest* pCTest;
unsigned char* pStart = NULL;
unsigned char* pEnd = NULL;
pCTest = &oCTest;
pStart = (unsigned char*)pCTest;
pEnd = (unsigned char*)(++pCTest);
//size gives the size of the object oCTest.
size_t size = pEnd – pStart;
FarPointer said
Nice One.