We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3baa616 commit 5f51085Copy full SHA for 5f51085
Polymorphism/RuntimePolymorphism.cpp
@@ -0,0 +1,46 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+class Base
5
+{
6
+public:
7
+ void display()
8
+ {
9
+ cout << "\nDisplay Base";
10
+ }
11
12
+ virtual void show()
13
14
+ cout << "\nShow Base";
15
16
+};
17
18
+class Derived : public Base
19
20
21
22
23
+ cout << "\nDisplay derived";
24
25
26
+ void show()
27
28
+ cout << "\nShow derived";
29
30
31
32
+int main()
33
34
+ Base B;
35
+ Derived D;
36
+ Base *bptr;
37
+ cout << "bptr points to base";
38
+ bptr = &B;
39
+ bptr->display();
40
+ bptr->show();
41
+ cout << "\nbptr points to derived";
42
+ bptr = &D;
43
44
45
+ return 0;
46
+}
Polymorphism/RuntimePolymorphism.exe
44.9 KB
0 commit comments