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++ : Structure with Pointer with program example , what is Structure with Pointer in c++ language in hindi

what is Structure with Pointer in c++ language in hindi , C++ : Structure with Pointer with program example :-
इससे पहले एक article मे string को pointer variable से declare और access करने के लिए प्रोसेस को discuss किया है अब इस article मे structure मे pointer variable से  initail ओए access करने के प्रोसेस को discuss किया गया है |
structure
struture  एक mixed data type होता है जिसमे कई दो या दो से अधिक डट type के variable को member की तरह hold कर सकते है | उदाहरण के लिए time एक structure है जिसमे hour value ,minute value और second value को रखता है | structure data type एक यूजर define data type भी कहते है | क्योकि structure  के type के दुसरे variable को declare किया जाता है | इस प्रोसेस को समजने के लिए निन्म उदाहरण को consider करेगे :-
#include<iostream.h>
#include<conio.h>
#include<string.h>
struct time
{
int hour ;
int minute;
int second;
};
void main()
{
using namespace std;
time t;
cout<<“Enter hour Value :”<<endl;
cin>>t.hour;
cout<<“Enter Minute Value :”<<endl;
cin>>t.minute;
cout<<“Enter Second Value :”<<endl;
cin>>t.second;
cout<<“Time :”<< t.hour:t.minute : t.second <<endl;
getch();
}
इस उदाहरण मे time एक structure है जिसमे तीन member है :-
hour : इसमें hour value को assign किया जाता है|
minute : इसमें minute value को assign किया जाता है |
second : इसमें second value assign किया जाता है |
t.hour  का मतलब है की time variable के member hour हो access किया जाता है | और t.minute से time variable के minute member को access करते है |
structure with new operator
new operator से string को declare किये जाता है और new operator से array को declare करने से complie time पर , array को create नहीं किया जाताहै |और new operator से  run time मे array को create किया जाता है | जब किसी  structure को run time मे allocate किया जाता है तब इसके लिए new operator को use किया जाता है | इसे dynamic structure कहते है | यहा पर dynamic का मतलब है र्रून time पर struture को के लिए memory space को allocate किया जाता है |
structure को new operator से allocate किया जाता है :
inflatable *pointer name = new inflatable;
यहा पर
inflatable : ये structure  का नाम होता है जिसके लिए memory space को define किया जाता है |
pointer name : ये pointer का नाम है |जिसमे structure  का मेम्रोरी address store होता है |
new : ये key word है जिसका use new operator के use करने के लिए किया जाता है |
new operator से structure मे दो operation हो सकता है :
1. create
2. Access
किसी structure को pointer variable से create करने के लिए new operator का use किया जाता है | और किसी structure के member को access करने के लिए डॉट operator का use नहीं किया जाता है | इसके लिए c++ मे (->) का use किया जाता है | इसे arrow membership operator कहते है |  इसका उदाहरण के लिए :
#include<iostream.h>
#include<conio.h>
#include<string.h>
struct time
{
int hour ;
int minute;
int second;
};
void main()
{
using namespace std;
time *t = new time;
cout<<“Enter hour Value :”<<endl;
cin>>(*t)->hour;
cout<<“Enter Minute Value :”<<endl;
cin>>(*t)->minute;
cout<<“Enter Second Value :”<<endl;
cin>>(*t)->second;
cout<<“Time :”<< (*t)->hour:(*t)->minute : (*t)->second <<endl;
getch();
}
इस उदाहरण मे time एक structure है जिसमे तीन member है :-
hour : इसमें hour value को assign किया जाता है|
minute : इसमें minute value को assign किया जाता है |
second : इसमें second value assign किया जाता है |
इसमें  pointer variable जिसका type time data type है  | इस variable मे new operator से memory space के address को store किया जाता है |
(*t)->second : t pointer variable के second member को access करते है |
New और delete operator
जब किसी प्रोग्राम मे new operator को use किया जाता है | तब delete operator को use किया जाता है |  अब इस उदाहरण मे , new और delete operator के द्वारा  किसी string मे data को store किया जाता है | और get() function से एक pointer को return करते है जिसमे string को return किया जाता है |इस उदाहरण मे , एक temporary array मे यूजर द्वारा input string को read किया जाता है | और new [] operator से  एक string को declare किया जाता है | जिसे एक pointer variable मे assign किया जाता है |
उदहारण के लिए , अगर किसी प्रोग्राम मे 1000 string को read करना है और सबसे बड़ी string 79 character hold करती है तब अगर character array को use किया जाता है |तब 1000*80=80,000 bytes की जरुरत होती है | जो की बहुत बड़ी मेम्रोरी space है | इस प्रॉब्लम को solve करने के लिए char type के 1000 pointer को create किया जाता है | और new operator से केवल उन्ही string के लिए space को allocate करते है |जिन्हें use करना है |
उदाहरण :
#include<iostream.h>
#include<conio.h>
#include<string.h>
char *get(void);
void main()
{
char *n;
n=get();
cout<<n << “at”<<(int*)n;
delete[] n;
n= get();
cout<<n<<“at”<<(int*)n;
delete[]n;
getch();
}
char *get()
{
char temp[30];
cout<<“Enter Name :”<<endl;
cin>>temp;
char *p=new char[strlen(temp)+1];
strcpy(p,temp);
getch();
}
इस article मे ,  pointer variable से structure को initial और access करने के प्रोसेस को discuss किया गया है | अब आगे के article मे  c++ operator के relation operator को discuss करेगे |
Sbistudy

Recent Posts

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

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

22 hours 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