What error occurs without this C++ statement?

Asked By 10 points N/A Posted on -
qa-featured

Why we use this statement in C++ program?

usingnamespace std;

Does any error occur without it?

SHARE
Best Answer by Chalk Talk
Best Answer
Best Answer
Answered By 0 points N/A #124171

What error occurs without this C++ statement?

qa-featured

Namespaces in C++ and their usage can be compared to another level of organization. If the creation of programs was to be done on single screen, then you will probably need the Namespaces.

But since many of the commercial programs that are developed are very long, then that means the different developers who team to create it may end up using the same code for some other purpose and that may cause a clash that will affect the runability of the program. So to decrease or sidestep the risk that may lead to such a clash Namespaces are used.

The Namespaces are useful when it comes to grouping items together that have similar characteristics.

Chalk Talk

 

Answered By 0 points N/A #124172

What error occurs without this C++ statement?

qa-featured

Hi Eleanor Rithi !

By adding "Using namespace std" we can use  all the names which are present in std  to the current scope.(like cout ,cin) for example if we want to print something we have to use cout but if we have not declared using namespace std then compiler will give an error that cout is undeclare identifier so if you don't want to use this you have to use std::cout<<" "; for the output purpose but by adding namespace we can direct use cout statement .

We can also avoid using namespace by changing #include <iostream> to #include <iostream.h>

Hope that you can understand .

Thanks 

Login/Register to Answer

Related Questions