Using namespace std

◀ General Traps and Tips▶ Flush the Output Buffer
Amazon Throughout this book you see many examples in which the statement, using namespace std;, is placed in their headers. This statement is called a using directive.

<iostream> is recognized by only C++ programs. This header is C++ new style. Headers ending with .h are generally old style. If you use <iostream.h>, you probably do not need to include using namespace std; in the program’s header.

If you use <iostream>, you should include using namespace std; in the header so that the functions and other elements in <iostream> are made available to your program.

In essence, it is possible that there are more than one package that supports the same function. In that case, how does a compiler know which version the function refers to? The functions, classes, and various other elements that belong to standard C++ libraries are packaged in a namespace called std, short for standard.
This leads to the fact that, for example, cin is really std::cin and cout is really std::cout. However, if you need to type std::cin in place of cin, you will be disgruntled like a pig. That is why the C++ committee decided to add the using directive as a standard feature.

When you use the statement, 'using namespace std;', you no longer need to prefix the definitions in the std namespace with std::.
Next let’s look at what output buffer is and how to flush it properly!
◀ General Traps and Tips▶ Flush the Output Buffer

Questions? Let me know!