What is Inheritance in C++ ?

No comments

 Inheritance :-  It allows the extension and reuse of existing code with out having to re- write the code. Inheritance involves the creation of new classes from an existing class. New classes are called derived class /new class/child class/ sub-class and existing class is called base class /old class/parent class/ super class. The derive class inherit the members of base class and also add its own.


Example:- class A
                              {
                                         Int x;
                                         Public:
                                          Void display()
                                                 {
                                                       Cout <<x;
                                                 }
                                    };

                              Class B : public A
                                                   {
                                                          Int y;
                                                           Public:
                                                            Void show()
                                                                    {
                                                                         C out <<y;
                                                                      }
                                                         };

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀