I am newbie to namespace usage in C++. Can anyone clarify me the below queries?
Can one namespace be derived from another namespace?Can c++ namespace be derived from c++ class?Also can c++ class be derived from c++ namespace?
I am newbie to namespace usage in C++. Can anyone clarify me the below queries?
Can one namespace be derived from another namespace?Can c++ namespace be derived from c++ class?Also can c++ class be derived from c++ namespace?
That depends on what you mean by "derive". It certainly cannot be derived in the same way that classes can, but you could say, make an alias for an existing namespace.Originally Posted by leo2008
No.Originally Posted by leo2008
No.Originally Posted by leo2008
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
a namespace is a container. that is all. you cannot allocate memory for a namespace, because it does not represent storage. you cannot instantiate a namespace because it is not a type. it's simply a place to put things to keep them organized. let's say you have a program that links two libraries: one for communicating over a network connection, and another for communicating with the user via the console. let's say they both implement a function called ReadLine(). without namespaces, those two functions would conflict. but let's say we put the network library in a namespace called Network, and the console library in a namespace called Console. now you can call Console::GetLine() or Network::GetLine(), and they don't conflict. get it?