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++ : namespace , method to declare and directive in c++ language , program example source code in hindi

program example source code in hindi , c++ : namespace , method to declare and directive in c++ language :-
इससे पहले के article मे , namespace को discuss किया था अब इस article मे name को declare और directive करने के method को discuss करेगे | c++ language मे namespace को दो प्रकार से mechanism को बनाया गया है |
1.using declatarion
2.using Directive
दोनों method से namespace को use करने के method को सरल करता है | using declatarion  method से namespace के element / name को use किया जा सकता है और using Directive से पुरे namespace को एक साथ use किया जासकता है |  निन्म उदहारण मे
namespace pick{
double stick ;     // variable declare
void acess();      // Funciotn declare
int b;           // variable declare
struct pick_value{….}; // struture declare
}
namespace put {
double bucket (double n ){……..}     // Funciotn declare
void acess();      // variable declare
int b;           // variable declare
struct  pick_value{….}; // struture declare
}इस उदाहरन मे दो namespace को declare किया गया है \
1.pick : इसमें 4 name है | पहला stick है जिसमे से वाले को pick करना है | दूसरा acess function का नाम है जिसका use वाले को access करने के लिए किया जाता हो | और  pick_value struture का नाम है जिसमे pick की गयी value को hold किया जाता है |
1.put : इसमें 4 name है | पहला bucket है जिसमे pick की गयी values को put करना है | दूसरा acess function का नाम है जिसका use, access की गयी value को use करने के लिए किया जाता है | और  pick_value struture का नाम है जिसमे pick की गयी value को hold किया जाता है |

1.using declatarion
इन namespace को acess करने के लिए using declatarion method को निन्म तरह से use करते है :-
using pick : : acess ; // using declatarion

using declatarion method मे namespace मे से name को किसी declartion region के फिक्स किया जा सकता है | उपर वाले उदहारण मे , name space pick के function access () के लिए declatarion region main() होता है  | इस declartion के बाद access () function को main() function मे कभी भी use किया जा सकता है |
अतः code इस तरह होगा |
namespace pick{
double stick ;     // variable declare
void acess();      // Funciotn declare
int b;           // variable declare
struct pick_value{….}; // struture declare
}
char access ;
int main()
{
using pick :: access ;
int acess ;
cin>>acess ;
cin>>::acess ;
}

using declartion region  से name का scope local होता है | और जब किसी दुसरे name access को declare किया जाता है | तब इस statement से global name को local name से ओवरराइड हो जाता है |

using declartion region से name space मे नए name को add किया जाता है इसके लिए निन्म उदाहरन को consider करेगे |
void other ()
{
namespace pick{
double stick ;     // variable declare
void acess();      // Funciotn declare
int b;           // variable declare
struct pick_value{….}; // struture declare
}
using pick :: acess ()
int main()
{
cin>>access;
other ;
……;
}
void other ()
{
cout<<acess ;
……
}

namespace pick{
double stick ;     // variable declare
void acess();      // Funciotn declare
int b;           // variable declare
struct pick_value{….}; // struture declare
}

2.using Directive
using Directive method से namespace के सभी names को use किया जा सकता है | using Directive से किसी namespace के names को add किया जाता है | ये namespace के सभी names को include किया जाता है  इसका syntax निन्म होता है :
using namespace pick;

जब किसी namespace को global  declare किया जाता है | इस namespace के सभी name को प्रोगार्म के किसी भाग मे use किया जा सकता है | इससे पहले कई उदाहरनो मे हमने देखा है की
#include<iostream>
using namespace std;
जब किसी namespace को using Directive से किसी function मे add किया जाता है तब इस namespace को केवल इस function मे use किया जासकता है  |  इसका उदहारण निन्म है :
int main()
{
using namespace pick ;
}

जब किसी using Directive या  using declatarion  को use किया जाता है तब इससे name मे confusion होता है | जब दोनों pick और put namespace को उज्से किया जासकता है तब in namespace से variable a को use किया जाता है तब name मे confusion हो सकता है |

using Directive method मे namespace मे से name को किसी region मे use किया जा सकता है | उपर वाले उदहारण मे , name space pick के function access () के लिए declatarion region main() के अलावा function add() मे भी use किया जा सकता है  | इस declartion के बाद access () function को main() function और add() मे कभी भी use किया जा सकता है |
अतः code इस तरह होगा |
namespace pick{
double stick ;     // variable declare
void acess();      // Funciotn declare
int b;           // variable declare
struct pick_value{….}; // struture declare
}
char access ;
using namespace pick;
int main()
{
int acess ;
cin>>acess ;
cin>>::acess ;
}
void add()
{
pick ::a;
::a=10 ;
cout<<“value :”<<a;
}

using Directive region  से name का scope global होता है | और जब किसी दुसरे name access को declare किया जाता है जिसका variable local scope होता है तब इस statement से global name को local name से ओवरराइड हो जाता है |

इस article मे namespace को access करने के लिए method को discuss किया है आगे के article मे  using Directive  और  using declaration के बारे मे advance topic को discuss करेगे |

Sbistudy

Recent Posts

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

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

18 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