+ 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

5th Sep 2020, 4:46 PM
sid
sid - avatar
3 Antworten
+ 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.
5th Sep 2020, 4:57 PM
Muneeb Bhalli
Muneeb Bhalli - avatar
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
15th Nov 2020, 6:14 PM
cs_s0uM
cs_s0uM - avatar