#include <cstdlib>
#include <iostream>
using namespace std;
class Base
{
public:
void func(){cout<<"Base.func"<<endl;}
};
class Derived:public Base
{
public:
void func(){cout<<"Derived.func"<<endl;}
};
class TypeInfo
{
public:
TypeInfo();
TypeInfo(std::type_info&info){myInfo = &info;}
TypeInfo(const TypeInfo&);
TypeInfo& operator=(const TypeInfo&);
bool before(const TypeInfo&)const;
const char* name()const;
private:
std::type_info* myInfo;
};
class NullType;
struct EmptyType
{};
void fun(Base* pObj)
{
TypeInfo info = typeid(Derived);
if(typeid(*pObj) == info){
pObj->func();
}
delete pObj;
}