+ 7
What is the mean of ' using namespace std ; ' ?
please give me that answer
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
+ 5
may you give a example of code ?
+ 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 ?
+ 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
}
+ 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.
+ 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.