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

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

10 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

10 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

2 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

2 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months 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