-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicbinding.cpp
More file actions
28 lines (28 loc) · 833 Bytes
/
Copy pathDynamicbinding.cpp
File metadata and controls
28 lines (28 loc) · 833 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
#include<iostream>
using namespace std;
class car{
public:
virtual void acon()
{
cout<<"AC of car class"<<endl;
}
};
class sportscar:public car
{
public:
void acon() //method overrriding
{
cout<<"AC of sports car"<<endl;
}
};
int main()
{
sportscar A;
car *p;
// A.acon(); //early binding
p=&A; //Base class pointer storing the address of child class object (Base class pointer to child class object)
p->acon(); //early binding only checks the type of object or pointer class
// virtual keyword is applied then the object of base class hence it will check the content of object call
return 0;
}
// for dynamic binding we use virtual functions