Results 1 to 3 of 3

Thread: namespace

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    namespace

    ok, if i create structures or constants, or classes thaat already have been declared in C++, can i create a namespace for my program, so that it wont matter?(i know what namespaces are, i just wanna know if i can put my whole program in them)
    Thanks
    Amon Ra
    The Power of Learning.

  2. #2
    jim mcnamara
    Guest
    Yes, namespaces are just for data abstraction, so you can put your whole program in one.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Not data abstraction, just to prevent name collisions. For example, you could do this:
    Code:
    #include <iostream>
    
    namespace MyProgram {
        class string {
            // Your own string class
        };
    };
    
    int main() {
        std::string x = "Hello";
        MyProgram::string y = "Another";
    
        return 0;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width