C++基础 多态实现——利用虚方法实现父类指针调用子类方法
#include <iostream>
class Father {
public:
Father() {};
virtual void Say()
{
std::cout << "I'm father!" << std::endl;
}
};
class Son :public Father {
public:
Son() {};
void Say()
{
std::cout << "I'm son..." <<.
原创
2022-04-10 16:47:38 ·
200 阅读 ·
0 评论