13年题。

This commit is contained in:
unlockable
2023-06-02 00:03:58 +08:00
parent 955977fef2
commit 9cecf352c2
11 changed files with 401 additions and 0 deletions

33
OOP/13Exam/2.1.cpp Normal file
View File

@@ -0,0 +1,33 @@
// 在下面基类Base和派生类Derived中增加成员函数show使得程序运行结果如下
// Base
// Derived
#include <iostream>
using namespace std;
class Base {
public:
// _________________________;
virtual void show() {
cout << "Base" << endl;
}
};
class Derived : public Base {
public:
// __________________________;
virtual void show() {
cout << "Derived" << endl;
}
};
int main() {
Base b, *ptr;
Derived d;
ptr = &b;
ptr->show();
ptr = &d;
ptr->show();
return 0;
};