+ 7

What is the mean of ' using namespace std ; ' ?

please give me that answer

20th Oct 2016, 9:33 AM
{ sood(Hemant , Prakash); }
{ sood(Hemant , Prakash); } - avatar
6 Antworten
+ 6
it is for importing the std namespace into your code. if you don't include that line of code, you will have to prefix cout like std::cout, cin becomes std::cin, endl becomes std::endl. Therefore, it makes your lines of code shorter when you write using namespace std. pls note: std isn't the only namespace you can use in your code. you can create your own namespace and use in your codes. read chapter on namespaces
20th Oct 2016, 10:04 AM
yungcheda
yungcheda - avatar
+ 5
may you give a example of code ?
20th Oct 2016, 10:06 AM
{ sood(Hemant , Prakash); }
{ sood(Hemant , Prakash); } - avatar
+ 5
Is my code run if I don't write std::cout or std::cin ? can I use direct cin or cout without write std::cout or std::cin ?
20th Oct 2016, 10:16 AM
{ sood(Hemant , Prakash); }
{ sood(Hemant , Prakash); } - avatar
+ 4
namespace is created to be used as additional information to differentiate functions, classes, variables with the same name available in different libraries. we can say, a namespace tells us the scope of our code an example is namespace namespace_name { // code declarations }
20th Oct 2016, 10:18 AM
yungcheda
yungcheda - avatar
+ 3
when we include some header files like iostream, we must unlock its doors to use them, like cout or cin and ... . so we use using namespace std; to unlock all of them. we could use : std::cin; std::cout; to unlock only cin and cout instead of unlocking all.
20th Oct 2016, 10:01 AM
Mahdi Afshar
Mahdi Afshar - avatar
+ 3
it won't run until you declare them. you can test these on a playground or an ide and see the results and errors.
20th Oct 2016, 10:20 AM
Mahdi Afshar
Mahdi Afshar - avatar