What is Inheritance in C++ in Hindi - इनहेरिटेंस क्या हे हिंदी में ?

हेल्लो दोस्तों ,आज की इस (What is Inheritance in C++ in Hindi ) आर्टिकल के अन्दर हम C++ Language के Inheritance के बारे में जानकारी देने वाले हे , ये Inheritance OOPs (Object Oriented Programming ) के एक Features हे , जो काफी Important Concept हे | हमने हमारे पिछले आर्टिकल के अन्दर इस OOPs के बारे में Discuss किये थे , जिसके अन्दर हमने इस Inheritance के बारे में बात किये थे ,जो की Basic Concept था | और इसलिए इस पुरे आर्टिकल के अन्दर हम Inheritance के बारे में बहत ही आसान भासा में समझेंगे , क्यू की OOPs के अन्दर जो Features के Topic थे , वो सब बहत ही Important Topic थे , जिसे बहत ही अछे से समझना पड़ेगा , और इस लिए इस Inheritance को एक अलग आर्टिकल के अन्दर Cover कर रहे हे , ताकि आप लोग इस Concept को अछे से समझ के अपने Program के अन्दर Implement कर सको..., तो चलिए शुरू करते हे inheritance in c++ in hindi  ,,,


What is Inheritance in C++ in Hindi






 
 

What is Inheritance in C++ in Hindi - इनहेरिटेंस क्या हे हिंदी में ? 

Inheritance वो Concept होता हे जिसमे एक Class के Properties को किसी दुसरे Class के अन्दर Access कर सकते हे | मतलब जब Program में एक Class के अन्दर किसी और Class के Features और Properties को Use करना हो , तो इस Process के लिए हम इस Inheritance को इस्तेमाल करते हे |

इस Inheritance के अन्दर दो तरह के Class होते हे ,
  • 1. Base Class :- Base Class को Parents Class या फिर Super Class भी कह सकते हो ,
  • 2. Derived Class :- Derived Class को Child Class या फिर Sub Class कहा जाता हे |
Inheritance में Derived Class में Base Class के सभी Properties को Access किया जाता हे , जो की इस Colon (:) Symbol के मदत से किया जाता हे |
और Access करने के लिए Public, Private , Protected Mode में से किसी भी एक Mode को use करना होता हे , जिसमे Public Mode को जादा Use किया जाता हे | और इसके बजह से Base Class में जितने भी Data Member या फिर Member Function होते हे , वो सब Derived Class के Member बन जाते हे |
Syntax :-

class base
{
  // data
  // member
};
class derived : public base
{
  // data
  // member
};

तो ये रहा Inheritance का Concept , उम्मीद हे आप लोग समझ गये होंगे ,,,

Types of Inheritance in C++ in Hindi :-

C++ Programming के अन्दर इस Inheritance के 5 Types देखने को मिलता हे , जेइसे -
  1. Single Inheritance
  2. Multilevel Inheritance
  3. Multiple Inheritance
  4. Hierarchical Inheritance
  5. Hybrid Inheritance
आइये इन सारे Inheritance के Types के बारे में बिस्तार से जानते हे , और साथ में Practical Program करके भी देखेंगे , ताकि इन सारे Concept को आसानी से समझा जा सके |


1. Single Inheritance in C++ in Hindi :-

Single Inheritance वो होता हे जिसके अन्दर एक Base Class और एक Derived Class होते हे , और ये Derived Class Base Class के Properties को Access करता हे , इस Single Inheritance को Simple Inheritance भी कह सकते हो |



What is Inheritance in C++ in Hindi



 

Syntax :-

class base
{
   member of base class
};
class derived : public /private /protected
{
   member of derive class
};


तो ये होता हे Single Inheritance, चलिए इस Single Inheritance को एक Program के अन्दर Implement करके देखते हे |



What is Inheritance in C++ in Hindi

 


2. Multilevel Inheritance in C++ in Hindi :- 

Multilevel Inheritance में एक Base Class और Multiple Derived Class को Use किया जाता हे , मतलब एक Base class और एक से जादा Derived class को contains करते हे |



What is Inheritance in C++ in Hindi



Syntax :-

class base
{
  member of base class
};
class derived 1 : public /private /protected base
{
  member of derived 1 class
};
class derived 2 :public /private /protected derived 1
{
  member of derived 2 class
};


चलिए इस Multilevel Inheritance को भी एक Program के अन्दर Implement करके देखते हे |



What is Inheritance in C++ in Hindi

2nd Part :-


What is Inheritance in C++ in Hindi




3. Multiple Inheritance in C++ in Hindi :-

Multiple Inheritance में एक से जादा Base Class और एक Single Derived Class को Use किया जाता हे |



What is Inheritance in C++ in Hindi

 


देखो इस Flow Chat में हमने एक Derived Class के साथ 3 Base Class को Use किया हे , आप लोग इससे जादा Base Class को भी Use कर सकते हो |

Syntax :-

class base 1
{
  member of class base 1
};
class base 2
{
 member of class base 2
};
class derived : public / private /protected , base 1 , base 2
{
 member of derived class
};


आइये इस Syntax को एक Program में Implement करके देखते हे |



What is Inheritance in C++ in Hindi

2nd Part :

What is Inheritance in C++ in Hindi




4. Hierarchical Inheritance in C++ in Hindi :-

Hierarchical Inheritance में एक Base Class और एक से जादा Derived Class को Use किया जाता हे , लेकिन जो Derived Class होगा वो आसानी से Base के Properties को Access कर सकता हे , जिसमे वो Derived Class अपना Data Member को तो Access करेगा , और साथ में Base Class के Data Member को भी Access करेगा | तो इस Concept को ही Hierarchical Inheritance कहा जाता हे |



What is Inheritance in C++ in Hindi

 

Syntax :-

class base
{
  member of base class
};
class derived 1 : public / private / protected base
{
  member of derived 1 class
};
class derived 2 : public / private / protected base
{
  member of derived 2 class
};


इस Syntax को एक Program के अन्दर इस्तेमाल करके देखते हे |



What is Inheritance in C++ in Hindi

2nd Part :

What is Inheritance in C++ in Hindi






5. Hybrid Inheritance in C++ in Hindi :-

Hybrid Inheritance वो Inheritance होता हे , जिसमे एक से जादा Inheritance का Combination होता हे | जेइसे मानलो , हमने एक Single Inheritance और एक Multiple Inheritance को एक साथ Use किया , तो ये जो दो Inheritance का Combination होता हे , इसी Concept को Hybrid Inheritance कहा जाता हे |

आप लोग इस Inheritance के अन्दर किसी भी Inheritance का Combination को Use करके Program कर सकते हो , लेकिन इस Hybrid Inheritance में कम से कम 3 Class को Use किया जाता हे , इससे जादा भी Use कर सकते हो , लेकिन 3 Class को Use करना ही पड़ेगा , ये Compulsory होता हे |



What is Inheritance in C++ in Hindi




इस Flow chat के अन्दर हमने एक Single और एक Multiple Inheritance का इस्तेमाल किये हे |

Syntax :-

class A
{
  member of base class
};
class B :virtual public / private / protected A
{
  member of derived 1 class
};
class C :virtual public / private / protected A
{
  member of derived 2 class
};
class D : public A


इस Virtual Access Specifier के मदत से Class B और Class C को Class D के लिए Ignore करके Class D Direct Class A को Access कर सकता हे | अगर ये Virtual Access Specifier को Use नही किये तो , जब आप Program के अन्दर इस Inheritance का Use करेंगे तो ये आपको Error Show करेगा |

तो ये रहे Hybrid Inheritance का Concept , उम्मीद करता हु आप लोग समझ गये होंगे | आइये इस Inheritance को भी एक Program के अन्दर Implement करके देखते हे |



What is Inheritance in C++ in Hindi

 2nd Part : 

What is Inheritance in C++ in Hindi




अब इस Inheritance का Advantage और Disadvantage के बारे में भी जान लेते हे , ताकि इस Concept को और भी अछे से समझ जा सके ....

Advantage of Inheritance :-

1. Readability :- Inheritance के मदत से आप एक Class को अलग अलग Class के अन्दर Use कर सकते हो |

2. Save Time :- Class को Inherit करने से आपका टाइम बहत Save होता हे , जेइसे मानलो अपने एक Class को Create की हे , और फिर उसी Class को आप किसी और Class के अन्दर जहा उसे जरुरत होगी , उस Class के अन्दर Use कर सकते हो , इससे आपको Code को दुबारा से नही लिखना पड़ेगा | और इस तरह से आप एक Class के Code को अलग अलग Class के अन्दर Use कर सकते हो | जिसमे आपका काफी Time Save होगी , और जादा Effort भी नही लगेगा |

3. Errors :- जब आप एक Class के Code को अलग अलग Class के अन्दर Use करते हो , जिसमे उस Code के अन्दर किसी भी तरह के Error आने के Chance भी बहम कम होती हे , और आप उस Code को आसानी से Re use कर सकते हो |

तो इस Inheritance के मदत से Error को Reduce किया जाता हे |


Disadvantage of Inheritance :-

Speed :- जब एक Class किसी दुसरे Class के अन्दर Inherit किया जाता हे , तो उसमे Program के Speed काफी Slow हो जाता हे |

Change Effect :- जब एक Base Class को एक Derived Class के अन्दर Inherit किया जाता हे , और अगर मानलो उस Base Class के अन्दर किसी Code को Change या फिर Modify करना पड़े , तो उस Change का Effect उस Derived Class पे भी पड़ता हे |


तो ये कुछ Important Advantage और Disadvantage होते हे Inheritance के अन्दर , जिसके बारेमे जानना बहत जरुरी हे , तो उम्मीद करता हु आप लोग इस Concept को अछे से समझ गये होंगे |


Read More :- OOPs Concept in C++ in Hindi 

Conclusion :-

Inheritance का मतलब हे एक Class को किसी दुसरे Class के अन्दर Access करना , जिसमे Class के जो Features और Properties होते हे , वो सब उस दुसरे Class के अन्दर आजाते हे , जिस वो Class आसानी से Use भी कर सकता हे |

हमने आज की इस ( What is Inheritance in C++ in Hindi ) आर्टिकल के अन्दर Inheritance के बारे में पूरी जानकारी बहत ही आसान भासा में आप लोगो के साथ शेयर की ,और साथ में आपलोग ये भी जान गये हो की C++ में Inheritance का क्या फायदा हे ? तो उम्मीद करता हु आप लोगो को इस आर्टिकल के अन्दर दिए गये जानकारी पसंद आया हे , अगर पसंद आया तो ओने दोस्तों के साथ जरुर शेयर करे ,और अगर इस आर्टिकल के सम्बंधित किसी तरह के शाबाल या फिर कोई Doubt हे , तो निचे Comment करके पुच सकते हो |

Thank you....
Tags

एक टिप्पणी भेजें

0 टिप्पणियाँ
* Please Don't Spam Here. All the Comments are Reviewed by Admin.