Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. what is contained in iostream and std

what is contained in iostream and std

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonygeeker
    wrote on last edited by
    #1

    Hi,

    I am a newbee to c++.
    iostream include definition of cout and cin
    But if I write cout without std, It throws error, which should be corrcted to std::cout.
    Why so?

    A CPalliniC J 3 Replies Last reply
    0
    • A Anonygeeker

      Hi,

      I am a newbee to c++.
      iostream include definition of cout and cin
      But if I write cout without std, It throws error, which should be corrcted to std::cout.
      Why so?

      A Offline
      A Offline
      Albertjoss
      wrote on last edited by
      #2

      iostream and std are contains the standard library functions, Which are necessary and more often used in simple programs also. Read more

      1 Reply Last reply
      0
      • A Anonygeeker

        Hi,

        I am a newbee to c++.
        iostream include definition of cout and cin
        But if I write cout without std, It throws error, which should be corrcted to std::cout.
        Why so?

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        In order to have insight on > content, feel free to check out the documentation: [<iostream> - C++ Reference](http://www.cplusplus.com/reference/iostream/)[[^](http://www.cplusplus.com/reference/iostream/ "New Window")]. `std` is the [namespace](http://en.cppreference.com/w/cpp/language/namespace)[[^](http://en.cppreference.com/w/cpp/language/namespace "New Window")] of the `C++ Standard Library`, quoting [Wikipedia](https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library)[[^](https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library "New Window")]: _"Features of the C++ Standard Library are declared within the **std namespace**"_. In order to use objects, e.g. `cout` you need either to * Qualify it with the `std` namespace specifier, e.g. #include <iostream> int main() { std::cout << "hi" << std::endl; } or * Take advantge of the `using namespace std;` statement, e.g. #include <iostream> using namespace std; int main() { cout << "hi" << endl; }

        In testa che avete, signor di Ceprano?

        A 1 Reply Last reply
        0
        • CPalliniC CPallini

          In order to have insight on > content, feel free to check out the documentation: [<iostream> - C++ Reference](http://www.cplusplus.com/reference/iostream/)[[^](http://www.cplusplus.com/reference/iostream/ "New Window")]. `std` is the [namespace](http://en.cppreference.com/w/cpp/language/namespace)[[^](http://en.cppreference.com/w/cpp/language/namespace "New Window")] of the `C++ Standard Library`, quoting [Wikipedia](https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library)[[^](https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library "New Window")]: _"Features of the C++ Standard Library are declared within the **std namespace**"_. In order to use objects, e.g. `cout` you need either to * Qualify it with the `std` namespace specifier, e.g. #include <iostream> int main() { std::cout << "hi" << std::endl; } or * Take advantge of the `using namespace std;` statement, e.g. #include <iostream> using namespace std; int main() { cout << "hi" << endl; }

          A Offline
          A Offline
          Anonygeeker
          wrote on last edited by
          #4

          Hi, But how the std and cout is related?

          CPalliniC 1 Reply Last reply
          0
          • A Anonygeeker

            Hi, But how the std and cout is related?

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            cout belongs to std namespace. There is no global cout, there is just std::cout.

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • A Anonygeeker

              Hi,

              I am a newbee to c++.
              iostream include definition of cout and cin
              But if I write cout without std, It throws error, which should be corrcted to std::cout.
              Why so?

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              I would suggest that as a "newbee" to C++ that you should just consider the answer to this question to be 'magic'. The specifics of how this works this way and why it works is quite complicated and requires not only that you understand quite a bit of basic C++ but also that you understand a bit more about how programming works. After that then you can go back and look at this yourself and it should then your answer should be immediately clear.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups