JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

C++ : CLASS AND OBJECT , what is class and object in c++ language in hindi , class define , body

class define , body , C++ : CLASS AND OBJECT , what is class and object in c++ language in hindi :-
इससे पहले के article मे function ओवरलोडिंग को discuss किया है | अब इस article मे c++ language के सबसे महत्व पूर्ण topic class और object को discuss करेगे जिससे अतः इस article का c++ language मे सबसे ज्यादा उपयोगी है | अब इस article मे class और object के basic को discuss करेगे अतः आ इस article को जरुरी पढना |c++ language मे multiple conceptual language है इसका मतलब है की c++ language मे बहुत सारे additional concept को introduce किया गया है | अतः c++ language मे कई सारे programming language के concept को add किया गया है | सबसे common concept है object को बनाना |
जब किसी language मे  प्रॉब्लम को object बना कर solve किया जाता है इसे object oriented language कहते है | c++ एक object ओरिएंटेड language है |
c++ मे एक बहुत बड़े प्रोग्राम को छोटे छोटे भागो मे डिवाइड किया जाता है | इन छोटे छोटे भागो objects कहते है |
object data या function का collection होता है जिसे main() function मे use किया जाता है |

c++ class
किसी programming language मे object को बनाने से पहले class को define किया जाता है | class object की image होती है जिसमे object को define किया जाता है | जिस प्रकार कोई डिज़ाइनर किसी माकन को बनाने से पहले नक्शा बनता अहि उसी प्रकार object को बनाने से पहले class को design किया जाट है | जिस प्रकार एक design से कई सारे माकन को बनाया जाता है उसी प्रकार एव्क class से multiple object को बनाया सजा सकता है |

Class Define
class को define करने के लिए class keyword को use किया जाता है | class के बाद class का नाम होता है |{} मे class की body होती है | इसका syntax निन्म होता है :-
class class_name
{
class body ;
}
इस syntax मे निन्म है :
class: ये class को define करने के लिए class keyword है |
class_body : ये class की body मे जिसमे class को define किया जाता है |
class_name : ये class का नाम है जिसका इस्तेमाल class को use करने के लिए किया जाता है |

class body :
class की body मे function / data को define किया जाता है | इन function / data का access mode होता है | यहा तीन mode common है :
1.private : private keyword का use किसी function / data को private बनाने के लिए किया जाता है | private function / data को only class मे ही access किया जाता है |
Public: Public keyword का use किसी function / data को  public बनाने के लिए किया जाता है | public function / data को only class के बहार access किया जाता है |

class का उदहारण निन्म है :
class test
{
private int a,b;
public :
void input()
{
a=12;
}
int input2()
{
b=23;
return b;
}
};

इस उदहारण मे class test को define किया गया है | जिसमे दो data variable a,b को define किया गया है | जिसमे access type private है in data variable को class test मे use किया जाता है | इसमें input () और input2() function को declare किया गया है | in function का access type public है | इन functions को class के बहार use किया जाता है | इस function को main() function या दुसरे function ()मे भी use किया जा सकता है |

C++ Object
जब किसी class को define किया जाता है उसके बाद object को भी declare किया जाता है | इस object के लिए कोई भी memory और storage allocate नहीं होता है | इस class के function / data को use करने के लिए object को declare किया जाता है |
object को declare करने के लिए निन्म syntax को use किया जाता है :-
class_name object_name ;
इसमें object_name से ओबेजेक्ट को use किया जाता है | इसका उदहारण निन्म है :
class test
{
private int a,b;
public :
void input()
{
a=12;
}
int input2()
{
b=23;
return b;
}
};
void main()
{
test t;
}
इस उदहारण मे test type एक object t को declare किया गया है | इस class मे define function को use करने के लिए निन्म method को use करते है :-
क्लास के data memeber और function member को access करने के लिए डॉट operator को use किया जाता है | उदहारण के लिए
t.input() ;
t.input2 ();
इन statement से class test के दोनों functions को use किया जाता है |
इसका उदहारण निन्म है :
#include<iostream.h>
#include<conio.h>
using namespace std;
class test
{
private int a,b;
public :
void input(int e)
{
a=e;
cout<<“Value of a :”<<a;
}
int input2()
{
cout<<“Enter data : “<<endl;
cin>>b;
return b;
}
};
void main()
{
test t;
int object ;
t.input(23);
object = t.input();
cout<<“you enter object value :”<<object<<endl;
}

इस उदहारण मे उपर दिए class और object को discuss किया गया है इसका आउटपुट होगा :
Value of a : 23
Enter data : 12
you enter object value : 12

इस article मे class और object के basic को discuss करेगे | अब आगे के article मे क्लास के उदाहरानो को discuss करेगे जिससे अप सभी के class और object के concept clear हो सके |

Sbistudy

Recent Posts

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

4 weeks ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

4 weeks ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

4 weeks ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

4 weeks ago

चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi

chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…

1 month ago

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

1 month ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now