forked from mrchuanxu/RegularNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
importImpl.cpp
54 lines (51 loc) · 1.06 KB
/
importImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/***
* 一些难点
* 比较烦人的点
* 1. 虚析构函数的用法 体验一下继承 构造 ***/
#include <iostream>
using namespace std;
class Person{
public:
Person(){
cout << "I am person" << endl;
}
virtual ~Person(){
cout << "fuck off i am die" << endl;
}
virtual void read();
};
class People{
public:
virtual void eat() = 0;
People(){
cout << "I am people"<< curr<<endl;
}
virtual ~People(){
cout << "fuck off i am die again"<<endl;
}
private:
static int curr;
};
int People::curr = 42;
class Student:public People,protected Person{
public:
void eat(){
cout << "eat by some one" << endl;
}
Student(){
cout << "fuck student" << endl;
}
~Student(){
cout << "shift" << endl;
}
protected:
void read(){
cout << "already read" << endl;
}
};
int main(){
People *pt = new Student;
pt->eat();
delete pt;
return 0;
}