हिंदी माध्यम नोट्स
namespace in c++ language in hindi , what is name space in c language with source code program
c++ language मे name से variable , function , structure , enum , class और class member को define करता है | जब कोई programmer बड़े प्रोग्राम को design करता है तब name मे confusion हो सकता है | जब किसी class को दो या दो से अधिक source से use किया जा सकता अहि उसमे भी name मे consion हो सकता है | उदहारण के लिए , दो library को define किया जाता जिसमे class को declare किया जाता है इसका name add , sub और node | जब किसी प्रोग्राम मे पहली libarary मे से class add को use करना है और दुसरे library मे से class sub को use करना होता है और दोनों function मे node c;अस अलग लगा होता अहि तब name मे confusion होता है | इस प्रॉब्लम को name space प्रॉब्लम कहते है |
name space in c language
c++ language के name space को discuss करने से पहले namespace को discuss करेगे |
किसिस प्रोग्राम मे declarative region को जरुर देखा होगा | declarative region एस region होता है जिसमे declartion किया जाता है | उदाहरन के लिए global variable को main() function से बहार declare किया जाता है | इसका decalretive region main() function बहार होता होता है लेकिन local variable नको main() function के अंदर declare किया जाता है | इसके लिए main() की body decalretive region होता है |
इसका उदहारण होता है :
#include<iostream.h>
#include<conio.h>
int c;
void main()
{
int a,b;
cout<<“Enter Input : “;
cin>>a>>b;
c= a+b;
cout<<“Output :”<<c;
getch();
}
इस उदहारण मे , a और b local variable है इसे main() मे declare किया जाता है | और c global variable होता है इसे main() के बहार declare किया जाता है |
scope भी किसी variable का important property है | scope का मतलब होता है variable का effectiveness | अतः इसका मतलब है जब तब variable की active होता है | scope जब से variable को declare किया जाता है से लेकर variable को terminate तक होता है | scope , decalretive region से लाग होता अहि | उदहारण के लिए global variable के लिए scope पुरे प्रोग्राम होता है लेकिन local variable केवल main() होता अहि | या जिस function की body मे declare किया जाता है इसका scope केवल इस function मे होता है |
variable , scope के अन्दर भी active नहीं रहता है उदहारण के लिए किसी दुसरे variable को declare किया जाता है जिसका name किसी दुसरे variable से सामान होता है तब दुसरे variable की active ness को हाईड करा सकता है | local variable को global variable के असिपे को change किया जा सकता है | लेकिन दोनों variable का नाम सामान होता है |
नीचे दिए गये डायग्राम मे decalretive region, scope को बताया है |
Namespace in c++
c++ मे namespace को create किया जा सकता है | इसके लिए decalretive region के नए रूप को declare किया जाता है | decalretive region के नए रूप का मतलब है की variable को declare करने के लिए नए space को allocate करना | किस decalretive region के name , कसी दुसरे decalretive region के name से fusion नहीं होता है | और इसके अलावा namespace मे declare की गयी variable और function को इसे करने के लिए methodology को use किया जाता है |
उदाहरन के लिए :
namespace jack {
double poail ; // variable declare
void fetch(); // Funciotn declare
int pal; // variable declare
struct well {….}; // struture declare
}
namespace jill {
double bucket (double n ){……..} // Funciotn declare
void fetch; // variable declare
int pal; // variable declare
struct hill {….}; // struture declare
}
namespace को global level और किसी namespace के अन्दर declare किया जा सकता है | लेकिन इन namespace को block मे declare नहीं किया जा सकता है | name space मे declare name का external linking होता है |
यूजर define namespace के अलावा global namespace भी होता है | global name space को file level decalretive region मे declare किया जाता है | अतः global variable को global namespace मे ही declare किया जाता है |
इस उदहारण मे jack और jill namespace मे declare function , variable और struture name मे fusion नहीं होता है |
name space को declare और define करने के लिए name space की तरह होता है |
name space open होते है | किसी name space मे कभी भी name को add किया जासकता है | उदाहरन के लिए
namespace jill{
char * goose(const char *);
}
इस उदाहरन मे name jill मे एक नए name goose को add किया जा सकता है |
इस उदहारण मे jack namespace मे function fetch() को देफिएँ किया जाता है | इस function को नाम एस्पस के बाद declare किया जाता है | name space को define करने के लिए निन्म syntax को use किया जाता है :-
namesapce jack
{
void fetch ()
{
……..
……..
……..
}
}
इस article मे name space के basic को discuss किया है अब आगे एक article मे namespace के advance methodology को discuss करेगे |
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
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 ,…