Standard namespace problem

Hii,

I am relatively new to C ++ programming. I know that the functions cout, cin, etc. Defined in a standard namespace. But we also include the iostream header file to run the program.

So does it look like

 namespace std
   {

     declaration of cout 

     declaration of cin 

     ..... some other declarations etc....

   }

and actual implementations inside istream and ostream ... ????

Or vice versa?...??? as....

namespace std 
   {
     complete definition of cout 
     complete definition of cin  
     .........

   } 

and their signatures are simply placed in the iostream file, for example ...

iostream file 
  {
    std :: cout 
    std :: cin 
    .....

  }

Please provide any examples or links that you think will help me better understand.

+3
source share
4 answers

I know that the functions cout, cin, etc. defined in the standard namespace.

These are not functions, but global instances of basic_ostreamand basic_istream.

iostream .

, ( ..).

. , . , , iostream, :

namespace std {
  extern istream cin;
  extern ostream cout;
  extern ostream cerr;
  extern ostream clog;

  extern wistream wcin;
  extern wostream wcout;
  extern wostream wcerr;
  extern wostream wclog;
}
+4

. , , , .

EDIT: cin, cout .. extern - . (. UncleBens)

+2

cin cout - cerr , , iostream. .

+1

cin cout, , std iostream, .

, , std::ostream ostream, iostream. ostream, std::cout std::ostream.

+1

Source: https://habr.com/ru/post/1764503/


All Articles