The difference between include <iostream> and include <iostream.h> in C + +---->

Source: Internet
Author: User

To put it simply:. h is the header file for standard C, and No. h is the standard C + + header file, both of which are header files. The reason for the difference between these two forms is that the development history of C + + is decided, just right there are other people also ask this question, here I answer again (note that vs2008 and VS2005 support for standard C + + is the same):

1, take iostream and stdio.h for example, iostream is the library of C + +, stdio.h is the library of standard C.

2. The new C + + standard rejects the. h header file, so there is no iostream.h header file in the vs2005.

3, in the early VS version, such as VC6.0, with the old version of the C + + standard library, such as iostream.h, and then the standard library did not introduce namespaces. So the direct # include <iostream.h> is possible. But in vs2005, the new C + + standard library was used, with # include <iostream> only.

4. Namespaces can contain many things, such as function names, identifiers, data types, and so on. The new C + + standard puts the names in the standard library in the Std namespace, so after # include <iostream>, you must use the namespace STD of the standard library to use the classes and functions in the standard library, which is the using namespace std ;

5, for the standard library of C, for example, stdio.h, there is no concept of namespaces, so directly included can be used.

6, the new C + + standard library in order to unify the previous C standard library, the original C standard library has also been put into the Std namespace, and the original C standard library removed. h suffix, preceded by the letter "C", for example stdio.h becomes Cstdio, when used for # include < Cstdio>, whose contents are the same as # include <stdio.h>, but have to use the namespace STD, which is the using namespace std;

7, therefore, for the new C + + standard library, there is no. h header file, such as iostream, after the header file is included, you must use the STD namespace to use the contents of the library. For the C standard library, there are two methods of use, one is the old. h form, such as stdio.h directly containing it, and the other is in C + + unified form, such as Cstdio, and the C + + standard library, including the subsequent addition of using the namespace STD, can be used. It is recommended to use the following unified form, such as you want to both C and C + + libraries, you can write: #include <cstdio> #include <iostream>using namespace std;

The difference between include <iostream> and include <iostream.h> in C + +---->

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.