8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2be57dd commit 28ef940Copy full SHA for 28ef940
Polymorphism/1_VirtualKeyWord.cpp
@@ -0,0 +1,37 @@
1
+#include<iostream>
2
+
3
+class Parent {
4
5
+ public:
6
+ Parent() {
7
8
+ std::cout << "Parent Constructor" << std::endl;
9
+ }
10
11
+ virtual void getData() {
12
13
+ std::cout << "Parent getData" << std::endl;
14
15
+};
16
17
+class Child : public Parent {
18
19
20
+ Child() {
21
22
+ std::cout << "Child Constructor" << std::endl;
23
24
25
+ void getData() { //implicitely virtual comes here .......
26
27
+ std::cout << "Child getData" << std::endl;
28
29
30
31
+int main() {
32
33
+ Parent *obj = new Child();
34
+ obj->getData();
35
36
+ return 0;
37
+}
0 commit comments