So, I did the following exervice in an attempt to better understand it.
I created a data.cpp file:
And a main.cpp file
int value = 54;
extern const double pi = 3.1514;
Now, I do understand the principle behind namespaces. So don't worry. I'm not asking for a book on it
extern int value;
extern const double pi;
int main(int argc, char* argv)
using namespace std;
cout << "The value of pi is " << data::pi;
using namespace data;
std::cout << std::endl << "The value of value is " << value;
std::cout << "\n\n";
1. system("pause") doesn't give me a compile error? I even have to qualify cout and endl even though I have iostream included when under the data namespace... so it should give me an error
2. How do I return to the global namespace? It seems to me as soon as I start the using directive, I'm stuck to it.
3. Above I had to declare the externs. It didn't matter to the compiler I had the using directive for data. With no extern declaration it simply wouldn't compile. I understand this, but why then when I use the std namespace alone with no stdlib.h include does system() still gets recognized?