what is inheritance in c++ in hindi complete guide

what is inheritance in c++ in hindi 

what is inheritance in c++ in hindi

what is inheritance in c++ in hindi

 C++ ka important feature ‘Reusability’  hai. Iske thought ham kisi existing class ko many types se use kr sakte hai. Re-usability  means “ki class ko bar – bar testing & debugging karke use save kar diya jaye to uska use kai jagah per kiyaa jaa sakta hai, aur 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 Hindi C++ me following access specifier ya access control use kiyee jaate hai. jisme Public mode ka use sabse jyada hota hai.

* private    * protected   * public

what is inheritance in c++ in hindi

  1. Private Mode : Base class ke private member derived class se kabhi bhi inherit nahi kiyee jaa sakte hai. But bese class ke public & protected member derived class me private ban jayege.
  2. Public Mode : isme base class ke public member derived class me public aur base class ke protected members derived class me protected ban jaate 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 hindi

  • Single inheritance

isme ek derived class single base class se inherit rahti hai. aap log niche pic me dekh kr aasani se samajh sakte hai.

single-inheritance

  • Multilevel inheritance

iss inheritance me ek derived class ko ek base class se inherit kiya jaata hai aur fir ek aur class ko us derived class se inherit kar diya jaata hai.

Multilevel-inheritance-in -hindi

  • Multiple inheritance

isme 2 ya 2 se jyada Base class ko single derived class se inherit kiya jaata hai.

Multiple-inheritance

  • Hierarchical inheritance

is type ke inheritance me ek base class 2 ya 2 se jyada derived classes se inherited rahti hai.

Hierarchical-inheritance

  • Hybrid inheritance

Yah inheritance multilevel & hierarchical inheritance ka combination hota hai. aap isko image me dekh kar aur ache se samajh sakte hai.

Hybrid-inheritance

 

inheritance in c++ program in Hindi

#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();

}

important points about inheritance in c++  hindi

  1. 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 oops so default access specifier was private.
  4. A derived class inherits all things of base class.

Also read:- Friend Function in c++ with example

Also read:- What is copy constructor in hindi

Conclusion 

C++ me inheritance ek bahut useful method hai, jiske jariye ham ek class ki saari property dusri class me use kar sakte hai, jisse time ki bachat hoti hai.

so maine apni post “what is inheritance in c++ in hindi” me puri information dene ki kosis ki hai. ager apke pas koi question ho inheritance se related so aap hamse comment box ke jariye puch Sakte hai. if you Like this Article plz show your support from sharing this post on social media.

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons