//-------------------------------------------------------------------------------------------------- int main (int argc, char** argv) { Base* pBase = new Base; Derived* pDerived; pDerived = static_cast<Derived*>(pBase); pDerived->Dummy(); return 0; }
//************************************************************************************* // Main functions int main (int argc, char** argv) { Base* pBase = new Base; Base* pBaseToDerived = new Derived; Derived* pDerived; pDerived = dynamic_cast<Derived*>(pBaseToDerived); if(pDerived){ pDerived->Dummy(); } else{ cout<<"Null pointer"<<endl; } pDerived = dynamic_cast<Derived*>(pBase); if(pDerived){ pDerived->Dummy(); } else{ cout<<"Null pointer"<<endl; } return 0; }