In C++, inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such way, you can reuse, extend or modify the attributes and behaviors which are defined in other class. In C++, the class which inherits the members of another class is called derived class and the class whose members are inherited is called base class. The derived class is the specialized class for the base class. Single Level Inheritance When one class inherits another class, it is known as single level inheritance. Example:- #include <iostream> using namespace std; class Account { public: float salary = 60000; }; class Programmer: public Account { public: float bonus = 5000; }; int main(void) { ...
Find the Solutions for your day to day Code Challenges

Comments
Post a Comment