In "Single Inheritance" their is only one base-class and one derived-class.
Basically their is only one "Parent-class"(BASE CLASS) from which the properties / behavior will be inherited to the "Child-class"(DERIVED CLASS).
Syntax:-
Also visit ----
Introduction to Inheritance
Multiple Inheritance
For giving some suggestion please comment us or check our "Contact us" page. Also more update related to coding will be added in this Blog later on, so please get attached with this Blog by clicking the follow button. Thank you for your support and time...
Basically their is only one "Parent-class"(BASE CLASS) from which the properties / behavior will be inherited to the "Child-class"(DERIVED CLASS).
Block-Diagram
Syntax:-
Example of Single-Inheritance
#include<iostream> using namespace std; class Parent { protected: int a=10; }; class Child : public Parent //Inheriting the class { public: int b=2; void put() { cout<<"Sum is "<<a+b; //Using 'a' from the Parent class } }; int main() { Child x; //'x' is the object of class "Child" x.put(); //Calling the function "put()" }
Also visit ----
Introduction to Inheritance
Multiple Inheritance
For giving some suggestion please comment us or check our "Contact us" page. Also more update related to coding will be added in this Blog later on, so please get attached with this Blog by clicking the follow button. Thank you for your support and time...
0 Comments