-
Notifications
You must be signed in to change notification settings - Fork 2
/
T52.cpp
50 lines (38 loc) · 1.12 KB
/
T52.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
//全纯虚函数(Java版接口) 虚函数 纯虚函数 全纯虚函数
#include <iostream>
using namespace std;
class Programmer {
int _id;
string name;
int age;
};
//此类所有的函数,都是纯虚函数,相当于Java的接口
class IProgrammer_DB {
public:
virtual void insertProgrammer(Programmer programmer) = 0;
virtual void updateProgrammer(int _id, Programmer programmer) = 0;
virtual void deleteProgrammer(int _id) = 0;
virtual Programmer queryProgrammer(Programmer programmer) = 0;
};
//实现类
class Programmer_DB : IProgrammer_DB {
public:
void insertProgrammer(Programmer programmer) {
cout << " insertProgrammer " << endl;
}
void updateProgrammer(int _id, Programmer programmer) {
cout << " updateProgrammer " << endl;
}
void deleteProgrammer(int _id) {
cout << " deleteProgrammer " << endl;
}
Programmer queryProgrammer(Programmer programmer) {
cout << " queryProgrammer " << endl;
}
};
int main52() {
Programmer programmer;
Programmer_DB programmerDb;
programmerDb.insertProgrammer(programmer);
return 0;
}