need help with namespace in c++

This is a discussion on need help with namespace in c++ within the C++ Programming forums, part of the General Programming Boards category; I am newbie to namespace usage in C++. Can anyone clarify me the below queries? Can one namespace be derived ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    162

    Thumbs up need help with namespace in c++

    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?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Quote Originally Posted by leo2008
    Can one namespace be derived from another 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.

    Quote Originally Posted by leo2008
    Can c++ namespace be derived from c++ class?
    No.

    Quote Originally Posted by leo2008
    Also can c++ class be derived from c++ namespace?
    No.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,456
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using namespace ....
    By Lesshardtofind in forum C# Programming
    Replies: 3
    Last Post: 11-17-2012, 07:53 PM
  2. Friend of namespace or of namespace function?
    By Programmer_P in forum C++ Programming
    Replies: 18
    Last Post: 03-13-2011, 06:46 PM
  3. using namespace std?
    By Nathan1993 in forum C++ Programming
    Replies: 2
    Last Post: 08-22-2005, 09:33 AM
  4. Namespace
    By Hypercase in forum C++ Programming
    Replies: 2
    Last Post: 08-15-2005, 05:46 AM
  5. namespace std
    By blankstare77 in forum C++ Programming
    Replies: 27
    Last Post: 07-24-2005, 12:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21