आइये इस Inheritance के बारे में जानते हे , की ये Inheritance का Concept क्या होता हे , और Programming के अन्दर किस तरह हे इस्तेमाल किये जाते हे | इन सब को बहत ही अछे से और वो भी बहत ही आसान भासा में Discuss किया जायेगा , वो भी Practical Programming के साथ | तो चलिए शुरू करते हे What is Inheritance in Python in Hindi
What is Inheritance in Python in Hindi
Inheritance का मतलब हे जब हम Program के अन्दर Class को Define करते हे , तो वो Class किसी दुसरे Class के Properties और Features को Access कर सकता हे , इस Concept को ही Inheritance कहा जाता हे |मतलब , एक Class के Properties और Features को किसी दुसरे Class के अन्दर Access करना , इस Process को ही Inheritance कहते हे |
Inheritance में दो तरह के Class होते हे , 1. Parent Class जिसे Base Class या फिर Super Class भी कह सकते हो , और दूसरा , 2. Child Class जिसे Derived Class या Sub Class भी कह सकते हो |
और एक Class के Properties को किसी दुसरे Class के अन्दर Access करने के लिए इस (:) Symbol का इस्तेमाल किया जाता हे |
Syntax :-
class A :
// Properties
class B (A) :
//Properties
देखो इस Syntax के अन्दर हमने दो Class को Create किया हे , Class A और Class B , तो ये जो B Class हे , इसमें A Class के जो भी Properties होंगे वो सारे के सारे इस B Class में आजायेगा |
मतलब ये B Class A Class के सारे Properties को Access कर लेता हे इस Inheritance का Concept को इस्तेमाल करके |
तो ये होता हे Inheritance का Concept | उम्मीद करता हु आप लोग इस Concept को अछे से समझ गये होंगे |
चलिए इस Concept का इस्तेमाल करके एक Program बनाते हे , ताकि इस Concept को आप लोग और अछे से समझ पाओ |
देखो इस Program में Parent Class में जो Properties थे , वो Child Class के अन्दर Access किये गये हे ,
Types of Inheritance in Python :-
Python Programming में 5 तरह के Inheritance होते हे ,
- Single Inheritance
- Multiple Inheritance
- Multi level Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
1. Single Inheritance in Python in Hindi :-
Single Inheritance में एक Parent Class और एक Child Class होते हे | और ये Child Class Parent Class के सारे Properties को Access कर सकता हे | इसलिए इस Single Inheritance को Simple Inheritance भी कहा जाता हे |
Syntax :-
class parent :
// Properties
class child (parent) :
// Properties
2. Multiple Inheritance in Python in Hindi :-
Multiple Inheritance में एक Child Class और Multiple Parent Class को Contain किया जाता हे | और वो एक Child Class उन सब Parent Class के Properties को Access कर सकता हे |
Syntax :-
class parent 1 :
// Properties
class parent 2 :
// Properties
class parent 3 :
// Properties
class child (parent 1 , parent 2 , parent 3) :
// Properties
3. Multilevel Inheritance in Python in Hindi :-
Multilevel Inheritance में सिर्फ एक Parent Class और एक से जादा Child Class होते हे |
Syntax :-
class parent :
// Properties
class child 1 (parent) :
// Properties
class child 2 (child 1) :
// Properties
class child 3 (child 2) :
// Properties
देखो इस Syntax के अनुसार एक Single Parent Class और Multiple Child Class को Contains किया गया हे | जिसमे पहले Child 1 Class Parents Class के Properties को Access करता हे | और Child 2 Class Child 1 Class के Properties को Access करता हे | और इस तरह से एक एक करके जितने भी Child Class होंगे , उन सब के Properties को Access किया जाता हे |
तो ये हो गये , Multiple Inheritance का Concept , उम्मीद करता हु आप लोग इस Concept को अछे से समझ गये होंगे ,
4. Hierarchical Inheritance in Python in Hindi :-
Hierarchical में एक Single Parent Class और Multiple Child Class होते हे , लेकिन जो Child Class होते हे , वो उस Parent Class के Properties को आसानी से Access कर सकता हे , इस Concept को ही Hierarchical Inheritance कहा जाता हे |Syntax :-
class parent:
// Properties
class child 1 (parent) :
// Properties
class child 2 (parent)
// Properties
5. Hybrid Inheritance in Python in Hindi :-
Hybrid Inheritance में एक से जादा Inheritance का Combination होता हे , जेइसे मानलो , एक Simple Inheritance और Multiple Inheritance का Combination में जो Inheritance को Create किया जाता हे , उसे ही Hybrid Inheritance कहा जाता हे | मतलब , किसी भी Inheritance का Combination करके इस Hybrid Inheritance को Implement किया जाता हे |Conclusion :-
आज की इस आर्टिकल के अन्दर हमने देखा की Inheritance क्या होता हे , और किस तरह से Programming के अन्दर इस्तेमाल किये जाते हे, मतलब Inheritance और कुछ नही , बल्कि इस Inheritance के मदत से ही एक Class के Properties को किसी दुसरे Class में Access किया जाता हे , मतलब एक Class के Code को किसी दुसरे Class के अन्दर Re- use किया जाता हे |तो उम्मीद करता हु आप लोगो को ये (What is Inheritance in Python in Hindi) आर्टिकल पसंद आया होगा , और अगर इस आर्टिकल के अन्दर दिए गये जानकारी से आप लोगो को कोई भी शाबाल या फिर किसी भी तरह के Doubt हे तो निचे Comment करके जरुर बताये |
Thank You ...