🟣 C++ Language • Hindi Tutorial Lesson 6/20

what is class in C++


Clanguage में आप structure के बारे में पढ़ चुके है। Structure एक बहुत ही important concept # C++ object oriented paradigm को support करने के लिए structures को


classes के रूप में extend करके include किया गया है।


एक class भी structure की तरह ही अलग अलग data type के variables का group होती है। लेकिन classes में आप functions भी create कर सकते है, जो की structures में possible नहीं है। एक class data (variables ) और उससे related functions को एक साथ bind करने का माध्यम होती है। Classes में आप variables और functions को outside यूज़ से hide भी कर सकते है।


जैसा की आपको data types की tutorial में पहले बताया गया class एक user defined data type होती है। Class type किसी normal built in type की तरह ही act करती है। Class type के variables को objects कहा जाता है। इन object पर आप normal variables की तरह different operations perform कर सकते है।


Classes के अंदर create किये गए variables को data members कहा जाता है और functions को member functions कहा जाता है। आप देखेंगे तो पाएंगे की structures और classes का basic format एक जैसा ही होता है। लेकिन structures limited होते है। Structures की कुछ limitations निचे दी जा रही है।


Structure variables में आपस में कोई भी


operations perform नहीं किये जा सकते है।


Structure में data को hide करने का कोई mechanism नहीं होता है। पूरा data public होता


है। एक structure के द्वारा declare किये गए members को दूसरा structure नहीं यूज़ कर सकता है।


Structure में function नहीं declare किया जा सकता है।


Structures में जँहा पर ऊपर दी गयी limitations पायी जाती है। वही ये ही limitations classes में features बन जाती है। Classes के कुछ features के बारे में निचे दिया जा रहा है।


Class objects (variables) के साथ आप operations perform कर सकते है।


Classesз data(Variables, Functions)


को hide कर सकते है। इसके लिए आपको access modifiers provide किये जाते है।


एक class में declare किये गए public


members को दूसरी class यूज़ कर सकती है। इसे


inheritance कहा जाता है।


Classes reference type होती है। यानि सभी operations after original variables at effect करते है।