virt_one.cpp
来自「C/C++使用技巧1001例一书的配套代码」· C++ 代码 · 共 22 行
CPP
22 行
#include <iostream.h>
class Base {
public:
virtual void show_message(void) { cout << "This is the base class\n"; };
};
class Derived: public Base {
public:
virtual void show_message(void) { cout << "This is the derived class\n" ; };
};
void main(void)
{
Base *base_pointer = new Base;
base_pointer->show_message();
base_pointer = new Derived;
base_pointer->show_message();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?