Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*I just did this because I was bored*/
- //A namespace is basically a class but you can store var, func and classes in it!
- #include <iostream>
- using namespace std;
- namespace PROGRAM_1
- {
- int x = 18;
- int y = 34;
- }
- namespace PROGRAM_2
- {
- void Hello()
- {
- cout << "Hello world!" << endl;
- }
- }
- int main()
- {
- using namespace PROGRAM_2; //This means that you can use var and funcs without needing to type in the scope ::
- cout << PROGRAM_1::x + PROGRAM_1::y << endl; //Here we need to type :: because we didn't do: using namespace PROGRAM_1;
- Hello(); //If we didn't include using namespace PROGRAM_2; We would have to do: PROGRAM_2::Hello();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement