f1208.cpp
来自「it is a usefull thing」· C++ 代码 · 共 31 行
CPP
31 行
//=====================================
// f1208.cpp
// Virtual Function Problem
//=====================================
#include<iostream>
using namespace std;
//-------------------------------------
class Base{
public:
virtual Base* afn(){
cout<<"In Base class\n";
return this;
}
};//-----------------------------------
class Sub : public Base{
public:
Sub* afn(){
cout<<"In Sub class\n";
return this;
}
};//-----------------------------------
void test(Base& x){
Base* b;
b = x.afn();
}//------------------------------------
int main(){
test(Base());
test(Sub());
}//====================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?