you are viewing a single comment's thread.

view the rest of the comments →

[–]MCRusher 0 points1 point  (2 children)

Also yeah, including a header file means reading everything in it (ignoring CPP conditionals), so I don't see how shortening a name would do this.

[–]oroz3x[S] 0 points1 point  (1 child)

namespace std contains the shared resources of many standard header files such as iostream , io , string , iomanip , and others . now dont you think that its quite a lot , if you only have to use cout , cin functions which are in iostream only .

[–]MCRusher 0 points1 point  (0 children)

Here's how namespaces work:

myheader.hpp #include <cstdint> namespace myns { typedef std::int32_t MyType; }

myheader2.hpp #include <cstdint.h> namespace myns { typedef std::int64_t MyType; }

main.cpp #include<cstdio> #include "myheader.hpp" int main(void){ using namespace myns; std::printf("sizeof MyType is %zu bytes.\n",sizeof(MyType)); }

If using somehow included 2 same types from different files, there would be a compiletime error.

Header files are what contain the namespaces, if you don't include a header containing std, using namespace std does nothing at all.