t.cpp
663 Bytes
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
#include <iostream>
using namespace std;
class A
{
public:
virtual void get_debug(){cout<<"Task::get_debug()"<<endl;};
virtual ~A(){};
};
class Task : public virtual A
{
public:
virtual void get_debug(){cout<<"Task::get_debug()"<<endl;};
virtual ~Task(){};
};
class Displayed : public virtual A
{
public:
virtual void get_debug(){cout<<"Displayed::get_debug()"<<endl;};
virtual ~Displayed(){};
};
class Satellite: public Task, public Displayed
{
public:
virtual void get_debug(){cout<<"Satellite::get_debug()"<<endl;};
};
int main()
{
Satellite s;
Satellite *sp=&s;
Task* t=&s;
Displayed* d=&s;
t->get_debug();
d->get_debug();
sp->Displayed::get_debug();
}