cpp language explained

Solutions on MaxInterview for cpp language explained by the best coders in the world

showing results for - "cpp language explained"
Marlene
17 Oct 2019
1#include <iostream>
2using namespace std;
3class BaseClass {
4public:
5   void disp(){
6      cout<<"Function of Parent Class";
7   }
8};
9class DerivedClass: public BaseClass{
10public:
11   void disp() {
12      cout<<"Function of Child Class";
13   }
14};
15int main() {
16   /* Reference of base class pointing to
17    * the object of child class.
18    */
19   BaseClass obj = DerivedClass(); 
20   obj.disp();
21   return 0;
22}