JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

Declaring of C++ constructors , Use of constructors , exam program source code in hindi

इससे पहले के article मे , constructor को discuss किया जाता है | इससे पहले के article मे constructor के syntax और declare करने को discuss किया जाता है |
Declaring of C++ constructors
constructors को declare करने के लिए जिस functio age के लिए constructors को declare किया जता जाता है उसमे pass किये जाने वाले argument को constructors के लिए use किया जासकता है | उदहारण के लिए persoage constructorsमे pass किये गये argument की सख्या तीन होती है | क्योकि यूजर द्वारा केवल तीन value को लिए जाता है |  इसका syntax निन्म है :
persoage  (const char * name , int age  =0 , double salary  = 0.0 )
इस  constructors
पहला argument एक string का pointer है जिसमे persoage का name member से initial किया जाता है |
age : ये integer type variable है जिसमे persoage के age  को initail किया जाता है |
salary : ये double type variable है जिसमे persoage की salary को initail किया जाता है |
Use of constructors
c++ language मे , किसि object को initial करने क लिए दो method को use किया जाता है | दोनों ही method मे object को constructor से initial करने के लिए दो method को use किया जाता है |
सबसे पहले constructor को  explicit call किया जाता है |
persoage p = persoage  ( “parth” , 23 , 20,000 );
इस उदहारण से :
persoage object p के member variable name मे parth को initail किया जाता है |
persoage object p के member variable age  मे 23 को initail किया जाता है |
persoage object p के member variable salary मे 20,000 को initail किया जाता है |
दुसरे method मे constructor को implicit call किया जाता है | इसका syntax निन्म होता है :
persoage p( “meet” , 26 , 28,000 );
इस उदहारण से :
persoage object p के member variable name मे  meet को initial किया जाता है |
persoage object p के member variable age  मे 26 को initial किया जाता है |
persoage object p के member variable salary मे 23,000 को initial किया जाता है |
explicit constructor का format implicit constructor से complex होता है |
c++ language मे जब किसी c++ class को use किया जाता है तब c++ constructor को use किया जाता है |  जब किसी new operator का use किसी नए memory एलोकेशन को allocate करने के लिए use किया जाता है  तस्ब constructor को use किया जाता है |
persoage *p = new persoage  ( “parth” , 23 , 20,000 );
इस statement से persoage object को create किया जाता है जिसमे value को constructor के argument से initial किया जाता है | इस memory allocation से allocate memory space के address को pointer variable p मे assign किया जाता है | object का name नहीं होता है उसके pointer variable इस memory allocatioage को manage करने के लिए use किया जाता है |
constructor को किसी दुसरे class मे use करने के लिए दुसरे form को use किया जाता है |  कसी object को method को use करने के लिए use किया जासकता है | जैसे persoage मे show () एक functioage है तब इसे invoke करने के लिए किया जाता है:-
p.show();
Default Constructor
Default Constructor एक एस Constructor है जिसे किसी object को initial करने के लिए use किया जाता है | और इस Constructor को exciplit call नहीं किया जाता है | नीचे दिए उदाहरन मे  Constructor को use किया जाता है  जिसे class object को declare करने के लिए किया जाता है |
persoage p;
इस statement को use किया जाता है इसे Constructor को declare किये बिना object को use किया जाता है | c++ मे default Constructor को आटोमेटिक supllies किया जाता है |
जब किसि Constructor को explicit declare किया जाता है तब इस method को use नहीं किया जाता है | किसी persoage classमे , default Constructor को use किया जाता है :-
persoage :: person()
{
}
इस method के बाद persoage object को create किया जाता है लेकिन इस method मे member कोunintail किया जाता है | जिसे
int a;
किसी default Constructor को use करना complex होता है |किसी Constructor को define नहीं किया जाता है लेकिन जब किसी Constructor को declare किया जाता है तब default Constructor को use किया जाता है | जब किसी noage default Constructor को use किया जाता है तब  default constructor को use नहीं किया जाता है |persoage p; से error message आ जाता है |
Constructor का उदाहरन :
persoage :: persoage (const char * employee  , int age =0 , double salary  = 0.0 )
{
std :: strcpy ( name ,employee ,50 );
name [50]=’\0′;
if(n<0)
{
std::cerr<<” age इस not negative”;
       << we set share equal to ‘0’ “<<endl;
share = 0 ;
}
else
age = age ;
salary = salary ;
total ();
}
अगर इस उदाहरन को defualt Constructor को use किया जाता है तब इसका निन्म code होगा :-
persoage :: persoage ()
{
std :: strcpy ( name ,employee ,50 );
name [50]=’\0′;
if(n<0)
{
std::cerr<<” age is not negative”;
       << we set share equal to ‘0’ “<<endl;
share = 0 ;
}
else
age = age ;
salary = salary ;
total ();
}
Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

2 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

6 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

6 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

6 days 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