JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

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

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

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

18 hours ago

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

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

18 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