|
-
Sep 14th, 2001, 07:53 PM
#1
Thread Starter
Hyperactive Member
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.
-
Sep 14th, 2001, 08:51 PM
#2
Yes, namespaces are just for data abstraction, so you can put your whole program in one.
-
Sep 15th, 2001, 06:25 AM
#3
Monday Morning Lunatic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|