这里的第二个演员给出了一个错误说
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
这是什么意思??
如果我使基类多态,为什么这会起作用?
有人可以让我知道这背后的基本概念吗?