许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

运行时类型识别 RTTI

代码

#include 
<iostream>
using namespace std;

class graphic
{
public:
    
virtual void display()=0;
};

class GIF:public graphic
{
    
public:
        
void display(){    cout << "GIF Image Showing." << endl; }
};

class PIC:public graphic
{
    
public:
        
void display(){        cout << "PIC Image Showing." << endl; }
};

void main()
{
    GIF gif;
    PIC pic;
    gif.display();
    pic.display();

    
bool bGif = typeid(gif) == typeid(GIF);
    
bool bPicEqualGif = typeid(pic) == typeid(GIF);
}


 

posted on 2010-12-03 09:08  许明会  阅读(152)  评论(0编辑  收藏  举报