Iostream and iostream. h, iostreamiostream. h

Source: Internet
Author: User

Iostream and iostream. h, iostreamiostream. h

To put it simply,. h is the header file of Standard C, and without. h is the header file of Standard C ++, both of which are header files. The reasons for these two forms are determined by the development history of C ++. Just now someone else asked this question, here I will try again (note that vs2008 and vs2005 have the same support for Standard C ++ ):

1. Take iostream and stdio. h as examples. iostream is a C ++ library and stdio. h is a standard C library.

2. The new C ++ standard abandons the. h header file, so there is no header file of iostream. h In vs2005.

3. In earlier versions of vs, such as VC6.0, the C ++ standard library of the old version was used, such as iostream. h. At that time, the standard library did not introduce the namespace. Therefore, direct # include <iostream. h> is acceptable. However, in vs2005, a new C ++ standard library is used, and only # include <iostream> can be used.

4. A namespace can contain many things, such as function names, identifiers, and data types. The new C ++ standard puts the names in the standard library into the std namespace. Therefore, after # include <iostream>, you must also use the standard library namespace std, to use classes and functions in the standard library, that is, using namespace std;

5. For the standard library of C, for example, stdio. h, there is no namespace concept, so it can be used directly after being included.

6. The new C ++ standard library puts the original C standard library into the std namespace in order to unify the previous c standard library, and removes the original C standard library. h suffix, followed by the letter "c", such as stdio. h is changed to cstdio, Which is # include <cstdio> when used, and its content and # include <stdio. h> same, but additional namespace std, that is, using namespace std;

7. Therefore, the new C ++ standard library is missing. header files in the format of h, such as iostream. After the header file is included, you must use the std namespace to use the content in the library. There are two methods to use the C standard library. One is to use the old one. h format, such as stdio. h can be directly included. The other is a unified form of C ++, such as cstdio, which is the same as the C ++ standard library and will be added with using namespace std; can be used. We recommend that you use the following uniform form. For example, if you want to use both C and C ++ libraries, you can write: # include <cstdio >#include <iostream> using namespace std;

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.