class CBase {};class CDerived1 : public CBase{ int a, b;};class CDerived2 : public CDerived1 { int c, d;};
and i have a list of CBase* pointers (these are pointing CDerived1, CDerived2)
now, Is there any way to know the size of the derived class just using CBase* pointer?
* I don't want to make another variable in base class
* I don't want to make any virtual function and add it in every derived classes
So I've tried like this
class CBase {};template <typename T>class CBase2 { size_t GetSize() { return sizeof(T); }}class CDerived1 : public CBase2<CDerived1>{}
It works good in both way (i can have list of CBase* pointers and satisfying 2 conditions above) but this has problem when CDerived2 inherites from CDerived1.
so i'm asking for a great advise and please let me know any kind of way to do that. thank you.