#include <iostream>
using namespace std;
class A
{
public:
virtual void show()
{
cout << "show A" << endl;
}
protected:
private:
};
class B:public A
{
public:
protected:
private:
virtual void show()
{
cout << "show B" << endl;
}
};
void main()
{
A* pa = new B();
pa->show();
cin.get();
}
#include <iostream>
using namespace std;
class A
{
public:
virtual void show()
{
cout << "show A" << endl;
}
protected:
private:
};
class B:public A
{
public:
protected:
private:
virtual void show()
{
cout << "show B" << endl;
}
};
void main()
{
B* pa = new B();//错误
pa->show();
cin.get();
}
using namespace std;
class A
{
public:
virtual void show()
{
cout << "show A" << endl;
}
protected:
private:
};
class B:public A
{
public:
protected:
private:
virtual void show()
{
cout << "show B" << endl;
}
};
void main()
{
A* pa = new B();
pa->show();
cin.get();
}
#include <iostream>
using namespace std;
class A
{
public:
virtual void show()
{
cout << "show A" << endl;
}
protected:
private:
};
class B:public A
{
public:
protected:
private:
virtual void show()
{
cout << "show B" << endl;
}
};
void main()
{
B* pa = new B();//错误
pa->show();
cin.get();
}