 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can implement the concept of pure virtual function in C++. Before starting, you can note my information. You can follow or subscribe my YouTube channel that is sanjaygupta underscore tech school. You can download my Android app that is Techimace, which is available on Google Play. Here you can see I have implemented a code in C++ which will demonstrate you how you can implement pure virtual function in C++. So first I have included a header file IO screen. Then STD namespace is used. Then a class stack is implemented, which is having two sections, protected and public. In protected section, two attributes, top and an array A is declared. Then in public section, two pure virtual functions are declared. To implement a declaration of pure virtual function, you have to use a keyword virtual. Then function declaration, which is followed by equals to zero. So in case of pure virtual function, base class doesn't have to provide their definition. The base class just provide declaration of pure virtual function. These functions will be defined by the class which will inherit this stack class that is base class. So you can see my stack is the derived class which is inheriting stack class. So now my stack class responsibility is to provide definitions of push and pop functions. So you can see here in public section, first constructor is implemented, which is initializing top value by minus one. Then push function is defined and then pop function is defined. So push is receiving an argument in x. Then top is incremented and x is assigned into A array at top position. Then pop is defining its definition. Here x is declared. Then top position value is assigned into x. Top is decremented and x is returned through this pop function. The benefit of pure virtual function is that the declaration which is available in base class will be defined in derived class. So function header declaration will be same as it is available in base class. So you can see return type of both the functions are same. Names are same and argument. Number of arguments are also same. So if you want to follow same function declaration in derived class, then you can declare those functions as pure virtual function in base class. In main function, you can see I have created object of derived class that is m. Then a message element pushed will be displayed on console. Then m.push this function will work and then pop function is called in this cout statement. So first five will be pushed inside the stack and then pop will pop that element and that element will be displayed on console. Now I am executing this code. You can see the message element pushed and pop element is five. So this way I have demonstrated you how you can implement pure virtual function in c++. Here in base class, these two statements are declaration of pure virtual function and these pure virtual function declarations are defined in derived class. So this way pure virtual function is implemented in C++. I hope you have understood the concept. If you want to watch more programming related videos, you can subscribe or follow my YouTube channel that is youtube slash sanjaygupta underscore tech school. Thank you for watching this video.