WhatsApp Group Join Now
Telegram Join Join Now

UNNAMED NAMESPACE AND FUTURE in c++ language in hindi explanation program example source code

in hindi explanation program example source code , UNNAMED NAMESPACE AND FUTURE in c++ language :-
इससे पहले article मे , namespace को discuss किया है | अब इस article मे unnamed namespace और इसके attributes को discuss करेगे |
namespace std ::
हमने इससे पहले कई उदाहरन मे namespace std को use किया है | लेकिन अभी तक इसे discuss नहीं किया है अब इस article मे इसे discuss करेगे | इसका syntax निन्म होता है :
#include<iostream.h>
{
using namespace std;
}
इस syntax से यह declare होता है की iostream header मे declare की सभी statement namespace std मे रखा जाता है | और using directive method से इस namespace को main() function मे access किया जा सकता है | इसका उदाहरन निन्म है :
#include<iostream>
#include<conio>
using namespace std;
void main()
{
cout<<“Good Morning !I am hard ware 123121. “;
}
इस उदहारण मे using directive method से std को add किया जाता है | इस syntax से  namespace std से सभी name को namespace global मे shift किया जकता है | अगर सिस्टम मे namespace std नहीं है तब in दोनों  syntax को निन्म स्य्नब्ताक्स से replace किया जा सकता है | और
#include<iostream.h>
#include<conio>
void main()
{
cout<<“Good Morning !I am hard ware 123121. “;
}
किसी प्रोग्राम मे , using namespace std; को कम कम से use करना चाहिए क्योकि इससे प्रोग्राम मे complexity बढती है | क्योकि using स्त्स्तेमेंट scope resolution प्रॉब्लम को generate करते है |
इसके स्थान पर निन्म syntax को use किया जा सकता है :
int a;
std::cout<<“value : “<<endl;
std :: cin>>a;
std::cout<<“your enter “<<a;
या इसके अलावा निन्म syntax को use किया जा सकता है :
using std::cout;
using std::cin ;
using std::endl;
cout<<“value : “<<endl;
cin>>a;
cout<<“your enter “<<a;
Unnamed namespace
जब किसिस namespace को बिना name के declare करते है उसे unnamed namespace कहते है | उदाहरन के लिए :
namespace
{
int cat;
int dog;
}
इस प्रकार के namespace को use करने के लिए using directive method को use किया जाता है | इस namespace मे declare name का scope जब तक  active रहता है तब तक declartive region का end नहीं होता है और इस region मे unnamed namespace को declare किया जाता है |
जब  unnamed namespace को use किया जता है using directive और using declartion को use किया जा सकता है |
किसी unnamed namespace के name को एक या एक से अधिक file मे declare नहीं किया जा सकता है | चाहे दोनों file मे namespace को declare किया गया है |
इसे use कर्ण एके लिए static variable को use किया जाता है जिस्म इंटरनल linking होता है | C++ standard मे  किसी namespace मे  static  और  global keyword को बहुत कम ही use किया जाता है |
उदहारण के लिए :
static int count ;
int other();
void main()
{
…….;
…….;
}
int other ()
{
…….;
…….;
}
इस syntax को namespace से execute किया जाता है तब
name
{
int count ;
}
void main()
{
…….;
…….;
}
int other ()
{
…….;
…….;
}
Namespace or future
जब namespace को प्रोग्राम मे add किया गया तब programming स्टाइल मे निन्म future enhancement हुए |
1.किसी global variable के स्थान पर   namespace के names को use किया जाता है |
2.static global variable के स्थान पर unnamed namespace के name को use किया जाता है |
3.जब दो या दो से अधिक function या class की library को develop किया जाता है तब इन्हें namespace मे रखा जाता है | c++ मे तो std library को namespace को use करने ही call किया जाता है |
जब math.h को use किया जाता है तब namespace को use नहीं करना चाहिए | लेकिन जब cmath को use किया जाता है तब इसे namespace मे std के तरह call किया जा सकता है |
4.using directive को केवल old code को namespace मे convert करने के लिए किया जाता है |
5.header file को call करने के लिए using को use नहीं करना चाहिए | क्योकि using method से केवल name को access किया जा सकता है function को नहीं | लेकिन जब कभी header file को using के साथ use करना हो तो तब इसे #INCLUDE  के बाद declare करना चाहिए |
6.किसी namespace के name सको access करने के लिए scope resolution और using declaration को use किया जाता है  |
7.using declaration मे global scope के बजाय local scope को use करना चाहिए |
Namespace का use किसी बहुत बड़े programming प्रोजेक्ट को handle करने मे किया जाता है |
Namespace Summery
c++ मे multiple file मे programming को develop किया जाता है | इसके लिए header file को use करना चाहिए | जिससे multiple file के content को एक main प्रोग्राम मे use किया जा सकते है |source file को function file से अलग declare करना चाहिए | header file और source file मे यूजर define function को use करते हुए प्रोग्राम task को perform करता है |
इसके अलावा namespace को किसी large प्रोग्राम मे name conflict को दूर करने के लिए किया जाता है | namespace से किसी name का region और identifier को declare किया जाता है | और using method या scope resolution operator से in namespace को use किया जासकता है |
इस article मे namespace को declare किया है अब आगे के article मे namespace के उदाहरनो को discuss करेगे |