-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp9.cpp
48 lines (44 loc) · 852 Bytes
/
p9.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
#include <iostream>
using namespace std;
class A {
public:
void print() {
cout << "A is before BCDE." << endl; }};
class B : public A {
public:
void print() {
A::print();
cout << "B is before CDE." << endl; }};
class C : public A {
public:
void print() {
A::print();
cout << "C is before DE." << endl;}};
class D : public A {
public:
void print() {
A::print();
cout << "D is before E." << endl; }};
class E : public B {
public:
void print() {
B::print();
cout << "E is last." << endl;}};
int main() {
A a;
B b;
C c;
D d;
E e;
cout << "print() of each class:" << endl;
a.print();
cout << endl;
b.print();
cout << endl;
c.print();
cout << endl;
d.print();
cout << endl;
e.print();
return 0;
}