The difference between C + + iostream and iostream.h

Source: Internet
Author: User
#include <iostream.h> non-standard input and output streams
#include <iostream> standard input and output streams

In C + +, in order to avoid name definition conflicts, the definition of namespaces is introduced, that is, namespace.
When using <iostream.h> in code, the output can directly refer to cout<<x;//<iostream.h> inherits the standard library file of the C language and does not introduce a namespace definition, so it can be used directly.
When <iostream> is introduced into the code, the output needs to refer to std::cout<<x; if it is still the same as the original method.
When using <iostream>, introduce std:: There are the following methods:

1.
using namespace Std;
cout<<x;
2.
Using Std::cout;
cout<<x;
3.
The most basic std::cout<<x;

This time you should know why it is usually used with # include <iostream>,
Use the using namespace Std; If you don't use this, the latter two methods will be used when using cout.
Other header files are the same.
(There is ". h" is non-standard, C standard library functions, no ". h", it is necessary to use the command space, is C + +.) Part of it is not exactly ". h" and no ". h" differences. Example: Math.h and Cmath)

The difference between C + + iostream and iostream.h

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.