answersLogoWhite

0

Why is namespace std used in c?

Updated: 8/21/2019
User Avatar

Wiki User

8y ago

Best Answer

Namespaces in general help keep code organised and ultimately avoid polluting the global namespace. That is, multiple namespaces can use the same names for different purposes without causing name-clashes. A class, struct or union is also a namespace.

The std namespace contains all standard library names, including standard template library names. The namespace is also subdivided to separate different features of the library.

Although namespaces can make code less readable, you can import names into the global namespace to help simplify code without polluting the global namespace. This is achieved by importing names locally, within those functions and classes that specifically require those names. In trivial programs, it is common practice to import all standard library names into the global namespace but in real-world programs imports are highly localised.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is namespace std used in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the use of using namespace STD in c plus plus programming?

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;


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


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 <iostream> using namespace std;


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).


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


Fundamental components of a c plus plus program?

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


What are some disadvantages of using namespace in C?

Here's one: there's no namespace in C


How do you wrte aprogramme on c plus plus?

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


Is cin a function or object in c?

cin is an object........ An Example is // By Codex #include <iostream> using namespace std; int main(){ int age; cout << "How Old Are You?\n"; cin >> age; cout << "You are << age << years old\n"; system("pause") return 0; }


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.


Give an example of C plus plus program?

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