Here the second cast gives an error saying
cast.cc:35:35: error: cannot dynamic_cast ‘base’ (of type ‘class CBase*’) to type ‘class CDerived*’ (source type is not polymorphic)
CBase * base = new CDerived; CBase* pb; CDerived * der = new CDerived; CDerived* pd; pb = dynamic_cast<CBase*>(der); // ok: derived-to-base pd = dynamic_cast<CDerived*>(base); // wrong: base-to-derived What is meannt by this ??
And why this works if I make the base class polymorphic ?
Can some one please let me know the basic concept behind this.