All About C++

Get Pure Concepts of C++

Monday, 29 February 2016

What is namespace std in C++ with example code

What is namespace std in C++

Std is a namespace which is built-in in library files of C++. Std deals with the cin and cout.that is std tells to compiler that what is cin and cout.

A simple example of std to understand its concept

#include <iostream>

using namespace std;
void main() {
cout << "Hello World!" << endl;
system(“pause”);
}
Now without std namespace the same code will be written as

#include <iostream>
using namespace std;
void main() {
std::cout << "Hello World!" << std::endl;
system(“pause”);

}