-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolimorfizim.cpp
executable file
·73 lines (65 loc) · 1.43 KB
/
polimorfizim.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//çoklu kalıtım
#include <iostream>
using namespace std;
class Windowns98
{
protected:
int a;
public:
Windowns98(int _a):a(_a)
{
}
virtual void graph()
{
cout<<"Windowns 98\t"<<a<<endl;
}
};//class Windowns98
/*
Wİndowns xp windowsn 98 in üzerine kurulmuş bir işletim sistemidir
windowns xp 98 in bütün özelliklerine sahiptir çünkü 98 den türetilmiş bir sınıftır
örnek xp de açtığımız bir dosyayı 98 de açamayabiliriz
fakat 98 de açtığımızı xp de açarız bu programlar geçmişini bilir.
Eğer böyle birşey olmasaydı word 2003 ile yazılmış belgelere word 2007 tarafından açılmayacaktı
yada açılması için en baştan word 2003 ün yazılması gerekecekti.
bu da prtik bir iş değil bu polimorfizim ile hemen çözülebilecek bir problem...
örnekte görelim...
*/
class WindownsXP:public Windowns98
{
protected:
int b;
public:
WindownsXP(int _b,int _a):b(_b),Windowns98(_a)
{
}
void graph()
{
cout<<"Windowns XP\t"<<a<<"--"<<b<<endl;
}
};//class WindownsXP:public Windowns98
class Windowns7:public WindownsXP
{
protected:
int c;
public:
Windowns7(int _c , int _b , int _a):c(_c),WindownsXP(_b,_a)
{
}
void graph()
{
cout<<"Windowns 7\t"<<a<<"--"<<b<<"--"<<c<<endl;
}
};//class Windowns7:public WindownsXP
void graph(Windowns98 *S)
{
S->graph();
}
int main()
{
Windowns98 s1(1);
WindownsXP s2(2,1);
Windowns7 s3(3,2,1);
graph(&s1);
graph(&s2);
graph(&s3);
}