L
Lasse Skyum
I'm wondering if there is any way to do run-time checking for the size of
class-instances?
The only idea I've come up with is overloading operator new and saving the
size passes to it on the instance itself.
class CMyClassA
{
public:
int a;
};
class CMyClassA : public CMyClassB
{
public:
int b;
};
void test(CMyClassA *pPtr)
{
// Here I would like to know the size of the instance that pPtr points
to...
}
int main(int argc, char* argv[])
{
CMyClassB MyInstance;
test(&MyInstance);
}
BTW, this is for a garbagecollector I'm working on just for fun and learning
stuff....
class-instances?
The only idea I've come up with is overloading operator new and saving the
size passes to it on the instance itself.
class CMyClassA
{
public:
int a;
};
class CMyClassA : public CMyClassB
{
public:
int b;
};
void test(CMyClassA *pPtr)
{
// Here I would like to know the size of the instance that pPtr points
to...
}
int main(int argc, char* argv[])
{
CMyClassB MyInstance;
test(&MyInstance);
}
BTW, this is for a garbagecollector I'm working on just for fun and learning
stuff....