+ 3
Why someone use std::cout while they can just use cout..
Is it related with namespace ,Does it have any advantage over normal declarations
3 ответов
+ 5
in c++ you have to include the namespace's/ the libraries before using their functionality.
For example:
using namespace std; //This includes the namespace in the project workspace
so we can use cout in our workspace but if you dont want to include the namespaces u can just tell the computer to use the namespace for a specific tasks using (namespace:thefunctionname)
for example :
std::cout
people use this technique to save memory in large programs as no one wants to include a whole library/namespace just to use a single function present in it.
0
std:cout: A namespace is a declarative region inside which something is defined. So, in that case, cout is defined in the std namespace. Thus, std::cout states that is cout defined in the std namespace otherwise to use the definition of cout which is defined in std namespace
source: google