P
puzzlecracker
after reading some of the post I found out something rather radical to
my previous understanding: that when you do
#include<iostream>
#include<string>
#include<vector>
etc
compiler puts those .h files into the namespace std -.h files that
contain all the declarations for vector, string, etc...
and after using namespace std you import everything inside.
My previous understanding was that each of heretofore mentioned .h
files declaration were already contained within std namespace;
something like that:
iostream.h
namespace std
{
class sstream;
etc
....
}
string.h
namespace std
{
class basic_string;
etc
....
}
and so on..
By including those files, you just let a compiler know where those
definitions are located, and "using namespace" just brings those
declarations into the global namespace.
My question: what is going on, how does namespace and include
communicate? How can I tell compiler to include my .h files into my (or
maybe std) namespace?
reflection: I noticed that by NOT including #include<string>
Prefixing it with std (std::string.. std::endl) works... why, if it is
not put there by compiler (or is it a default)?
THANKS THANKS THANKS
my previous understanding: that when you do
#include<iostream>
#include<string>
#include<vector>
etc
compiler puts those .h files into the namespace std -.h files that
contain all the declarations for vector, string, etc...
and after using namespace std you import everything inside.
My previous understanding was that each of heretofore mentioned .h
files declaration were already contained within std namespace;
something like that:
iostream.h
namespace std
{
class sstream;
etc
....
}
string.h
namespace std
{
class basic_string;
etc
....
}
and so on..
By including those files, you just let a compiler know where those
definitions are located, and "using namespace" just brings those
declarations into the global namespace.
My question: what is going on, how does namespace and include
communicate? How can I tell compiler to include my .h files into my (or
maybe std) namespace?
reflection: I noticed that by NOT including #include<string>
Prefixing it with std (std::string.. std::endl) works... why, if it is
not put there by compiler (or is it a default)?
THANKS THANKS THANKS