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

reference in c++ language , what is References vs Pointers , References as Parameters ,as Return Value

References as Parameters ,as Return Value , reference in c++ language , what is References vs Pointers :-
इससे पहले के article मे namespace और template को discuss किया था अब इस article मे  reference variable को discuss करेगे जो की c++ language का बहुत महत्व  पूर्ण concept है |
reference variable का use किसी variable को name से जोड़ने के लिए किया जाता अहि | variable को पहले declare किया जता है | जब किसी variable के लिए reference को initail किया जाता है तब reference name या variable दोनों को variable के लिए use किया जा सकता है |
References vs Pointers
reference को pointer मे थोडा समानता होती है | लेकिन इन दोनों concept मे काफी difference होता है | इस्मा difference निन्म होता है :-
कभी कभी किसिसी reference variable को null declare नहीं किया जा सकता है | reference variable को किसिस variable के लिए एक storage को occupy कर्ण एके लिए use किया जाता है |
जब किसि reference variable के लिए object को declare किया जाता है तब इसे किसि दुसरे object के लिए use नहीं किया जा सकता है | लेकिन pointer variable को किसि दुसरे variable को कभी भी utilize किया जा सकता है |
reference variable को जब create किया जाता है initial किया जाता है जबकि pointer variable को कभी भी initail किया जाता है |
Creating References in C++
जब किसी variable को memory को access करने के लिए variable name को use किया जाता है | और reference को किसी variable के memory को access करने के लिए use किया जासकता है | और जब किसी variable को memory को allocate करने के लिए variable name को use किया जाता है | और reference को  भी किसी variable के memory को allocate करने के लिए use किया जासकता है | इसका उदाहरन निन्म है :
int a = 17;
variable a के लिए reference को declare करने के लिए निन्म syntax है :-
int& r = i;
किसी reference को declare करने  लिए ‘&’ को use किया जाता है | इस syntax से reference ‘r’ को declare किया जाता है जिसे ‘a’ की value से initial किया जाता है |
उदाहरन 1 :
इस उदाहरन मे reference ‘r’ को declare किया जाता है जिसे ‘a’ की value से initial किया जाता है | और इसके अलवा refDouble, double type reference है जिसे double variable f के लिए use किया जाता है |
Source code
#include <iostream>
using namespace std;
int main () {
// declare simple variables
int    a;
double f;
// declare reference variables
int&    ref  = a;
double& refDouble = f;
a = 12;
cout << “Value of a : ” << a << endl;
cout << “Value of  reference a : ” << a << endl;
f = 134.7;
cout << “Value of f  : ” << f  << endl;
cout << “Value of reference  f  ” << refDouble  << endl;
return 0;
}
जब उपर वाले उदाहरनो को execute किया जाता है जब इसका
Value of a : 12
Value of reference a : 12
Value of f : 134.7
Value of reference f : 134.7References को किसी function argument lists और function return values की तरह use किया जा सकता है | आगे इन concept को discuss किया जाता है |

1 References as Parameters
जब किसी reference को function parameter मे pass किया जाता है तब इस method को call by reference कहते है | इस method मे pass की गयी reference को नार्मल variable से ज्यादा अच्छा रहता है |
उदाहरन 2  :
इस उदाहरन मे reference ‘r’ को declare किया जाता है जिसे ‘a’ की value से initial किया जाता है | और इसके अलवा ‘f’, double type reference है जिसे double variable b के लिए use किया जाता है |इसके बाद दोनों reference को function multiplication() मे pass किया जाता है |
Source code
#include <iostream>
using namespace std;
void main () {
// declare simple variables
int a;
int b ;
cout << “Value of a : ” << endl;
cin>>a;
cout << “Value of b : ” << endl;
cin>>b;
int c = multiplication(a,b);
cout << “Output of multiplication :  ” <<c<< endl;
getch();
}
void multiplication(int &r , int &f )
{
int mul ;
mul = r*f;
return mul ;
}
2 Reference as Return Value
जब किसी reference को किसी function मे से return किया  जाता है तब  reference को return जा सकता है |
Source code
#include <iostream>
using namespace std;
void main () {
// declare simple variables
int a;
int b ;
cout << “Value of a : ” << endl;
cin>>a;
cout << “Value of b : ” << endl;
cin>>b;
int c = multiplication(a,b);
cout << “Output of multiplication :  ” <<c<< endl;
getch();
}
void multiplication( r , f )
{
int mul ;
mul = r*f;
return (&mul) ;
}

इस article मे reference को discuss किया जाता है |

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