Thread: Name spaces in C++

  1. #1
    Registered User
    Join Date
    Sep 2001

    Question Name spaces in C++

    Hi all,

    I am writting an application in Visual C++ and am having troubles linking the front end modules with the back end ones.

    Im getting hundreds of link errors and suspect its due to
    class/variable nameing conflicts.

    Someone suggested i use a feature called "name sapceing" but i cant find much info about it.

    Does anyone know how to use it and how data is shared using name spaceing.

    Any help would be much appreciated.

    Captain Fish.

  2. #2
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    namespace MyNames{
    int aVar = 10;
    // or any other stuff here (classes, functions, ...)
    // In other source file you can use the namespace like this:
    cout << MyNames::aVar;
    // ----- or -----
    using MyNames::aVar;
    cout << aVar;
    This is just a quick example. Please ask for more information if something is unclear.
    Making error is human, but for messing things thoroughly it takes a computer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-22-2008, 12:51 AM
  2. Tabs or Spaces
    By DavidP in forum A Brief History of
    Replies: 46
    Last Post: 04-08-2007, 11:45 AM
  3. saving a CString to binary file with trailing spaces
    By nineofhearts in forum C++ Programming
    Replies: 12
    Last Post: 01-03-2006, 11:53 AM
  4. Handling spaces in command line arguments
    By starkhorn in forum C++ Programming
    Replies: 7
    Last Post: 11-16-2004, 02:42 PM
  5. Replies: 5
    Last Post: 06-30-2003, 12:52 PM