JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

C++ : Structure ( Advance ) in hindi , explain structure on advance level in c++ language in hindi

explain structure on advance level in c++ language in hindi ,  C++ : Structure ( Advance ) in hindi :-
इससे पहले के article मे , Structure के basic को discuss किया है |अब इस article मे ,Structure के advance topic को discuss करेगे :-
1.Structure as Function Argument
Structure एक यूजर define data type है |इससे function मे argument की तरह pass किया जा सकता है | और Structure को function से return भी किया जा सकता है | Structure को function मे normal variable की तरह pass किया जा सकता है |
उदाहरण के लिए :
#include<iostream.h>
#include<conio.h>
struct book{
std::string name;
int year;
std::string author;
int price;
};
void print(book);
void main()
{
book b;
cout<<“Enter name of book”<<endl;
cin.get(b.name);
cou<<“Enter name of author”<<endl;
cin.get(b.author);
cout<<“Enter Price”<<endl;
cin>>price;
cout<<“Enter year of publish”<<endl;
cin>>year;
print(b);
getch();
}
void print(book b )
{
cout<<“Book Details”<<endl;
cout<<“Book Name :”<<p.name<<endl;
cout<<“Author Name : “<<p.author<,endl;
cout<<“Price : “<<p.price<<endl;
cout<<“Publish Year : “<<p.year<<endl;
}
इस उदाहरण मे , book एक structure है |जिसमे निन्म element होते है :
Name : book का नाम है |
Author Name : इसमें author का नाम है |
Price :   इसमें price स्टोर होता है |
Publish Year : इसमें पब्लिश का year store होता है |
void print () एक यूजर define function है जिसमे Structure के value को print करता है | print (b) ; function का call करता है इसमें केवल Structure का pass होता है |
किसी Structure को function मे से return किया जा सकता है | ये operation C language मे possible नहीं है | इसके syntax को निन्म उदाहरण से समजा सकता है |
#include<iostream.h>
#include<conio.h>
struct book{
std::string name;
int year;
std::string author;
int price;
};
book InputData(book);
void print(book);
void main()
{
book b;
b=inputData(b);
cout<<“Book Details”<<endl;
print(b);
getch();
}
book  InputData(book b)
{
cout<<“Enter name of book”<<endl;
cin.get(b.name);
cou<<“Enter name of author”<<endl;
cin.get(b.author);
cout<<“Enter Price”<<endl;
cin>>price;
cout<<“Enter year of publish”<<endl;
cin>>year;
}
void print(book b)
{
cout<<“Book Name :”<<p.name<<endl;
cout<<“Author Name : “<<p.author<,endl;
cout<<“Price : “<<p.price<<endl;
cout<<“Publish Year : “<<p.year<<endl;
}
इस उदाहरण मे दो यूजर define functions है :
1.book InputData(book);- इस function मे structure book के element को input किया जाता है | इसका return type book है |इस function से structure book  return होती है |
2.void print(book b);- इस function मे structure book के element को print किया जाता है | इसका return type void है |इस function से structure book  display  किया जाता  है |
Array of Structure
Structure मे array तो हो सकती है | लेकिन Structure की array को declare किया जा सकता है |c++ मे ये facility possible है | Structure की array को declare करने के लिए syntax normal array की तरह होता है | इसका syntax होगा :
book b[12];
इस syntax से book type के एक array बन जाएगी जिसमे 12 book की detail store हो सकती है |
पहली book की detail को अतोरे करने के लिए index method b[0] को use करते है | ये age बढती रहती है | b[1] ,b[2],b[3] ………………….. आदि | यहा पर b एक array है और book एक structure है | अगर किसी array element के memory location को access करना होता है तब membership operator को use किया जाता है |
जैसे
अगर पहले book के नाम को store करना होता है तब इसे b[0].name के memory address पर करेगे |
अगर पहले book की price को store करना होता हैतब इसे b[0].price  के memory address पर करेगे |
अगर पाचवे  book के नाम को store करना होता है तब इसे b[4].name के memory address पर करेगे |
अगर पांचवे book की price  को store करना होता हैतब इसे b[4].price  के memory address पर करेगे |
अगर last book के नाम को store करना होता है तब इसे b[11].name के memory address पर करेगे |
अगर last book के author के नाम को store करना होता है तब इसे b[11].author के memory address पर करेगे |
Initial of Array of Structure
Array of Structure  को initial करने के लिए array और structure दोनों के element को initial करने के लिए use किये गये syntax को use किया जाता है | इसका syntax होता है :
structure_name array_name[size]=
{
{ array_name[0].value1 ,array_name[0].value2,…………………},
{ array_name[1].value1 ,array_name[1].value2,…………………} ,
………………………………………………………………………………………… ,
};
यहा पर
structure_name : ये structure का नाम है जिसके type की array को create करना है |
array_name : ये array का नाम है |
size : Record के number को define करता है |
array_name[0].value1 : ये पहले record की पहली value को initial करता है |
array_name[0].value2 : ये पहले record की दूसरी value को initial करता है |
इसका उदाहरण है :
#include<iostream.h>
#include<conio.h>
struct book{
std::string name;
int year;
std::string author;
int price;
};
void print(book);
void main()
{
book b[2]
{
{“Wings of Fire “,1995,”Abdul kalam” , 200 },
{“The accidental Prime Minister” , 2018 ,” Man Mohan Singh ” , 210}
};
cout<<“Details Of First Book :”<<endl;
print(b[0]);
cout<<“Details Of Second Book :”<<endl;
print(b[1]);
getch();
}
void print(book b )
{
cout<<“Book Name :”<<p.name<<endl;
cout<<“Author Name : “<<p.author<,endl;
cout<<“Price : “<<p.price<<endl;
cout<<“Publish Year : “<<p.year<<endl;
}
इस उदाहरण मे Array of Structure  को use किया गया है | इसमें structure book की array को declare किया गया है जिसकी size ‘2’ है |अतः ये दो book की detail को store कर सकता है |
और b[0] से पहली book की information को print () मे pass किया गया है |
और b[1] से दुसरो book की information को print () function मे pass किया गया है |
इसका आउटपुट होगा :
Details Of First Book :
Book Name : Wings of Fire
Author Name : Abdul kalam
Price : 200
Publish Year : 1995
Details Of Second Book :
Book Name : The accidental Prime Minister
Author Name : Man Mohan Singh
Price : 210
Publish Year : 2018
Bit Field of Structure  Member
C++ मे , किसी Structure के member के द्वारा occupy किये जाने वाले bits को manage कर सकते है | इस तरह से आप अपने प्रोग्राम की space complexity को control कर सकते है | इस प्रोपर्टी के कारन एक data struture को create कर सकते है जिसे register कहते है | इसका syntax होता है :
struct register {
data type statement ;
data type statement ;
};
इसका उदाहरण है :
struct register
{
unsigned int SN : 4;
unsigned in : 4;
bool goodIn : 1;
double : 6;
};
आप इस Structure  को initial भी कर सकते है जैसे
register ={14, true,12.12};
Bit Field का use ,low level language मे किया जाता है |
इस article मे structure के advance concept को discuss किया है | Structure  के उदाहरण को देखने के लिए हमारे C language course के Structure  : Examples section मे जाकर Structure  के concept को revised कर सकते है |
Sbistudy

Recent Posts

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

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

16 hours ago

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

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

16 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