answersLogoWhite

0


Best Answer

No, the use of 'namespace std' is not compulsory. You can specifiy it on any object reference. Specifying 'namespace' simply provides a default value.

Contrast ...

using namespace std;

cout << "Hello world!" << endl;

... with ...

std::cout << "Hello world!" << std::endl;

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

You don't "have to" use "using namespace std;" in C++. It just makes typing easier. Here are two identical programs, one with, and one without.

#include

using namespace std;

int main () {

cout << "Hello C++ World!" << endl;

return 0;

}

#include

int main () {

std::cout << "Hello C++ World!" << std::endl;

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

The using namespace std statement identifies the default namespace when it is not explicitly stated in the code. If you did not specify a namespace, simple things like cout and endl would have to be specified as std::cout and std:endl.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the use of using namespace STD in c plus plus programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

In c plus plus Programming can you replace STDio header with using name space STD?

No. You can't use namespace std even if you include stdio.h. At the very least you must include stddef.h before you can use namespace std.


How do you solve this error under-fined symbol 'cin'in c plus plus?

#include &lt;iostream&gt; using namespace std;


What is namespace in c plus plus program?

A namespace is similar to a class in object oriented programming. A namespace contains functions defined by the programmer. for example namespace std contains functions like cout and cin.namespaces can be globaly declared like so: "using namespace std;"which includes all the functions located in the namespace std.if you only need to use cout you can globaly declare only cout like this "using std::cout;"orstd::cout


What does the use namespace STD syntax do?

The std namespace is the standard library, which includes many of the common data types, constants, structures, classes and functions that you will use to create C++ programs. There are very few non-trivial C++ programs that do no make use of at least some portion of the standard library at some point. Note that you need only include those portions you actually use; there is no need to include the entire standard library. Any built-in functions that require the standard library will include only as much as they need to, whether you yourself include those portions or not.


Program to find odd number up to range in c plus plus?

#include &lt;iostream&gt; using namespace std; int main() { for(int i = 0; i &lt;= 100; i++) { if(i % 2 != 0) { cout &lt;&lt; i &lt;&lt; endl; } } char wait; cin &gt;&gt; wait; return 0; }

Related questions

In c plus plus Programming can you replace STDio header with using name space STD?

No. You can't use namespace std even if you include stdio.h. At the very least you must include stddef.h before you can use namespace std.


How do you solve this error under-fined symbol 'cin'in c plus plus?

#include &lt;iostream&gt; using namespace std;


What is namespace in c plus plus program?

A namespace is similar to a class in object oriented programming. A namespace contains functions defined by the programmer. for example namespace std contains functions like cout and cin.namespaces can be globaly declared like so: "using namespace std;"which includes all the functions located in the namespace std.if you only need to use cout you can globaly declare only cout like this "using std::cout;"orstd::cout


What is the C plus plus directive that allows you to refer to classes in a namespace like STD?

A quick and simple way to do this would be to add 'std::' directly in front of the data type that requires it. For example: a vector data type, without the line of code 'using namespace std' would look like this: 'std::vector' (without the inverted commas).


How you can find greatest of three variables using c plus plus programming?

greatest = std::max (a, std::max(b, c));


How do you wrte aprogramme on c plus plus?

#include&lt;iostream&gt; int main() { using namespace std; cout&lt;&lt;"Hello world!"&lt;&lt;endl; return( 0 ); }


Give an example of C plus plus program?

#include&lt;iostream&gt; int main() { using namespace std; cout&lt;&lt;"Hello world!"&lt;&lt;endl; return(0); }


How do you limit the floating in C Plus Plus in output statement?

Use setprecision.Example:#include #include using namespace std; int main() { double f = 3.14159; cout


How do you start code programming?

Download Dev-C++. Just google it. Hello World: #include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello World" &lt;&lt; endl; }


In your program what if you do not provide the following directive in your code using namespacestd hint what will you need to do?

If you do not include the directive using namespace stdin your program, any references to objects in namespace std will need be be qualified with that namespace. For instance...cout


Fundamental components of a c plus plus program?

#include &lt;iostream&gt; using standard namespace std; int main() { cout &lt;&lt; "your prob shouldn't be taking c++"; return 0; }


What is the Logic to print the letters from A to Z without using printf in Turbo C plus plus?

#include&lt;iostream&gt; int main() { using namespace std; char c='A'; do { cout&lt;&lt;c; }while(c++&lt;'Z'); cout&lt;&lt;endl; }