why use name space std | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why use name space std

why not anything else?

18th Jul 2016, 9:39 AM
Abhishek Soni
Abhishek Soni - avatar
2 Answers
+ 1
using: You are going to use it namespace: To use what? A namespace std: The std namespace (where features of the C++ Standard Library, such as string or vector, are declared). After you write this instruction, if the compiler sees string it will know that you may be referring to std::string, and if it sees vector, it will know that you may be referring to std::vector. (Provided that you have included in your compilation unit the header files where they are defined, of course.) If you don't write it, when the compiler sees string or vector it will not know what you are refering to. You will need to explicitly tell it std::string or std::vector, and if you don't, you will get a compile error.
18th Jul 2016, 11:09 AM
Mahima Rajvir Singh
Mahima Rajvir Singh - avatar
+ 1
okay so default is using namespace std or u need to mention for string/vector its own format.. got it
18th Jul 2016, 11:12 AM
Abhishek Soni
Abhishek Soni - avatar