代码
#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);
}
#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);
}