what is contained in iostream and std
-
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? -
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?iostream and std are contains the standard library functions, Which are necessary and more often used in simple programs also. Read more
-
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?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 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; }
Hi, But how the std and cout is related?
-
Hi, But how the std and cout is related?
-
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?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.