what is inheritance in c++ in hindi

 C++ ka most important feature ‘Reusability’  hai. Iske Jariye ham Kisi existing class ko Kai types Se use Kr Sakte Hai.

Re-usability Ka Real Mean “Kisi Class ko bar – bar Testing & debugging Karke use save kar diya jata Hai, Aur jarurat padne per us Class Ka use Kisi Dusri Class Me Kisi Particuler Work ko krne ke liye Kiya jata hai, C++ me is feature ko inheritance kaha jaata hai.”

Simple Language me kahu to “Inheritance ek aisi process hai. Jisme kisi bhi ek class ki property ko dusri class me use kiya jaa sakta hai.

Mode Of Inheritance in C++ In Hindi

C++ me following access specifier ya access control Ka Use Kiya Jata Hai. Isme 3 Types Ke Mode Hote Hai, Jisme Public mode ka use Sabse Jyada Kiya Jata Hai.

* private    * protected   * public

inheritance mode limitation
inheritance mode limitation
  1. Private Mode: Base class Ke private member derived class Se kabhi bhi inherit Nahi kiyee jaa sakte hai. But Base Class ke public & protected member derived class me private ban Jayenge.
  2. Public Mode: Is Mode Me Base Class Ke public member derived class me public aur base class ke protected members derived class me protected ban Jate hai.
  3. Protected Mode: Ager derived class ko base class Se inherit kiya Jata hai to base class ke public & Protected Members derived class me protected bani.

Types Of Inheritance in C++ In Hindi

  • Single Inheritance

Single Inheritance Aisa inheritance Hota Hai Jisme Keval Ek Derived Class Single Base Class Se inherit Rahti hai. Isko Aap Badi Asaani Se Daigram Dekh Kar Samajh Sakte hai.

single-inheritance

  • Multilevel Inheritance

Multilevel In heritance Me Pahle Ek Derived Class Ko Base Class Se Inherit Kiya Jaata Hai Aur Uske Baad Us Derived Class Se Ek Aur Derived Class Ko Inherit Kr Diya Jata hai.

Multilevel-inheritance-in -hindi

  • Multiple Inheritance

Jab 2 Ya 2 Se Jyada Base Class Ko Kisi Ek Derived Class Se Inherit Kiya Jaata hai To Isko Multiple Inheritance Kahte hai.

Multiple-inheritance

  • Hierarchical Inheritance

Hierarchical Inheritance Me Ek Base Class 2 Ya 2 Se Jyada Derived Classes Se Inherit Rahti Hai.

Hierarchical-inheritance

  • Hybrid Inheritance

Hybrid Inheritance Multilevel & Hierarchical Inheritance Ka Combination Hota hai. Aap Isko Image Me Dekh Kr Aasani Se Samajh Sakte hai.

Hybrid-inheritance

Inheritance in C++ Program Example

#include<iostream.h>

#include<conio.h>

class student

{

private:

int rno;

char name[20];

public:

void out()

{ cout<<rno<<“\t”<<name<<“\t”;

}

void in()

{cout<<“enter roll no =”;

cin>>rno;

cout<<“enter name=”;

cin>>name;

}};

class sport : public student

{ private:

char game[20];

public:

void show()

{out();

cout<<game<<“\n”;

}

void get()

{ in();

cout<<“enter game= “;

cin>>game;

}};

void main()

{

clrscr();

sport s;

s.get();

s.show();

getch();

}

Most Important Points In Inheritance In C++ Hindi
  1. The base class also knows as super & parent class.
  2. Derived class also knows as sub & child class.
  3. If we inherit derived class to any base class no C++ so default access specifier was private.
  4. A derived class inherits all things of Base class.
Here Is The Video Guide To Learn What Is Inheritance In C++ In Hindi

Conclusion 

C++ Lnaguage me Inheritance Ek Bahut useful Function hai, Jiske Jariye ham ek class ki saari property dusri class me Use Kar Sakte hai, Jesse time Save Hota Hai.

Thankyou For Reading This Post, If You Like Than Share With Your Friends Of Social Media.

Related Post:

What is inline Function in C++ in Hindi Language Puri Jankari

What Is Friend Function in C++ With Example In Hindi

What is Constructor in C++ in Hindi with an example

More Tags: what is inheritance in C++ Complete Guide, inheritance in c++ with example program in Hindi, inheritance in c++ with types, inheritance in c++ with Diagram, what is inheritance in c++ with Simple example, what is inheritance in c++Hindii, Types Of Inheritance in Hindi.

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.