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

C++ : Reference Variable , Address variable in hindi what is Address variable within structure in c++ language

what is Address variable within structure in c++ language , C++ : Reference Variable , Address variable in hindi :-
इससे पहले के article मे  reference variable को discuss किया गया है | reference variable को function मे  use किया जाता है |  इस article मे reference variable को structure मे use करने के method को discuss करेगे |Address variable
c++ language मे ,  address variable ये variable होता है जिसमे किसी variable के address को hold करता है  | address variable किसी variable और दुसरे variable ]के बीच मे लिंक बनाते है | उदहारण के लिए variable value और v दोनों address variable है | जब किसी reference को  argument की तरह कार्य करता है तब function orginal data की  copy को pass किया जाता है |  किसी function मे pass by reference को use किया जाता है reference variable को pointer variable और नार्मल variable की जगह use किया जाता है |
int value = 120;
int &v = value  ;
इस  उदहारण मे value एक नार्मल variable है लेकिन  ‘v’ एक reference variable है इसमें  variable value की value को variable ‘a’ मे assign किया जाता है |
उदहारण के लिए :
#include<iostream.h>
#include<conio.h>
void main()
{
using namespace std;
int v=101;
int &value = v;
cout<<“value of v : “<<<<endl;
cout<<“value of value : “<<value<<endl;
v++;
cout<<“value of v : “<<v<<endl;
cout<<“value of value : “<<value<<endl;
cout<<“Address of v :”<<&v ;
cout<<“Address of value :”<<&value;
getch();
}

इस उदाहराण मे , निन्म आउटपुट होगा :
value of v : 101
value of value : 101
value of v : 102
value of value : 102
Address of v : 4400
Address of value :4400

Address variable within structure
reference variable को class और struture मे use किया जा सकता है | reference variable को यूजर define type data होता है |  किसी struture मे reference variable को use करना किसी basic variable के तरह ही होता है |  reference variable को use करने के लिए address operator ‘&’ को use किया जाता  है | लेकिन function मे किसी struture के address को return किया जाता है | reference variable को function मे return करने के लिए एक अलग method को use किया जाता है | अतः किसी function से struture reference variable को return करने के लिए const किओ use किया जाता है |
इसका उदाहरन निन्म है :
#include<iostream.h>
#include<conio.h>
struct student
{
char name [20];
int grade ;
int class;
};
void main()
{
student s= {“parth”,60,”2″};
next(s);
student s1;
s1= next(s);
cout<<“Student ‘s’ class : “<<s.class<<endl;
cout<<“Student ‘s1’ class : “<<s1.class<<endl;
getch();
}
const student &next ( student &s)
{
cout<<” Name :”<<s.name<<endl;
cout<<” Grade :”<<s.grade<<endl;
s.class++;
cout<<“Class :”<<s.class<<endl;
return s;
}

इस उदहारण मे  student एक struture है जिसमे तीन memebers है |
name[] ; ये character array है जिसमे student का नाम को assign किया जाता है |
class : ये class variable है जिसमे student के class को assign किया जाता है |
grade : ये integer type variable है जिसमे student के grade को assign किया जाता है |
main() function मे , student type s variable को use किया जाता है | जिसकी values को parth , 60 और 2 से initail किया जाता है | इसके बाद next () function मे struture variable ‘s’ को pass किया जाता है |
next() function मे struture की memeber class को increment किया जाता है | और struture की values को display किया जाता है | इसके अलावा एक और variable को declare किया जाता है | इसमें ‘s’ की value को next() की value को assign किया जाता है |

Temporary variable
जब c++ language मे  , actual parameter किसी reference variable से match नहीं होता है तब  Temporary variable को use किया जाता है | लेकिन c++ Temporary variable को तभी generate किया जाता है तब const reference को use किया जाता है | इसके अलावा Temporary variable को निन्म condition मे भी generate होता है :-
1.जब किसिस actual parameter का type सही है लेकिन इसकी value नहीं तब Temporary variable generate होता है |
2.जब किसी actual parameter को type गलत है लेकिन इस type को सही type मे convert किया जाता है तब Temporary variable generate होता है |
इसके उदहारण के लिए :
#include<iostream.h>
#include<conio.h>
void swapreference(int & a , int & b );
void main()
{
int value1 = 100;
int value2 = 200;
cout<<“Value1 :”<<value1;
cout<<“value 2 : “<< value2 ;
cout<<“Swap with reference :”<<endl;
swapreference(value1 , value2 );
cout<<“Value1 :”<<value1;
cout<<“value 2 : “<< value2 ;
getch();
}
void swapreference(int & a , int & b )
{
int temp;
temp = a;
a=b;
b=temp ;
}

इस उदहारण मे swaping function को call by reference को use किया जाता है  |void swapreference(int & a , int & b ) ; इस function मे reference variable को use किया जाता है |  इस उदहारण मे , c++ complier, दो  Temporary variable को generate किया जाता है | इसका आउटपुट होगा :
value1 : 100
value2:  200
Swap with reference :
value1 : 200
value2: 100

उदहारण -2
#include<iostream.h>
#include<conio.h>
int cube(int & a );
void main()
{
int number ;
cout<<“Enter Number : “<<endl;
cin>>number ;
int output = cube(number);
cout<<“Cube value : “<<output;
getch();
}
int cube(int & a )
{
return a*a*a;
}

इस उदहारण मे cube function को call by reference को use किया जाता है  |void cube(int & a ) ; इस function मे reference variable को use किया जाता है |  इस उदहारण मे , c++ complier, एक Temporary variable को generate किया जाता है | इसका आउटपुट होगा :
Enter Number : 3
Cube value : 27

इस article मे  structure के साथ reference variable को discuss किया है | और इसके अलावा Temporary variable को discuss किया जाता है |

Sbistudy

Recent Posts

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

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

1 day ago

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

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

3 days ago

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

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

5 days ago

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

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

5 days ago

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

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

5 days ago

FOURIER SERIES OF SAWTOOTH WAVE in hindi आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित

आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित FOURIER SERIES OF SAWTOOTH WAVE in…

1 week 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