13年题。
This commit is contained in:
31
OOP/13Exam/3.3.cpp
Normal file
31
OOP/13Exam/3.3.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
class Base {
|
||||
private:
|
||||
char c;
|
||||
|
||||
public:
|
||||
Base(char n): c(n) {}
|
||||
virtual ~Base() {
|
||||
cout << c;
|
||||
}
|
||||
};
|
||||
|
||||
class Der:public Base {
|
||||
private:
|
||||
char c;
|
||||
public:
|
||||
Der(char n):Base(n + 1), c(n) {}
|
||||
~Der(){
|
||||
cout << c;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
Der('X');
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
XY
|
||||
*/
|
||||
Reference in New Issue
Block a user