# What is the difference between include and # include?

Source: Internet
Author: User
# What is the difference between include <iostream> and # include <iostream. h> # include "iostream. h"
# Include <string>
Using namespace std;

Void main ()
{
String s1;

While (cin> s1)
Cout <s1 <endl;
}
This program adds. after h, it cannot be compiled. ========================================================== = many C ++ programmers are still using standard libraries instead of updating them.
What are the differences between the two? First, five years ago, we began to oppose the use of the. h symbol in the standard header.
File. It is not a good way to continue using outdated rules. In terms of functionality,
<Iostream> contains a series of templated I/O classes. On the contrary, <iostream. h> only supports characters.
Stream. In addition, the C ++ standard interface of the input/output stream has been improved in some subtle details. Therefore,
<Iostream> and <iostream. h> are different in terms of interfaces and execution. Finally, each group of <iostream>
Chengdu is declared as STL. However, the components of <iostream. h> are declared as global.

Because of these differences, you cannot confuse these two libraries in a program. As a kind of study
<Iostream> is generally used in new Code. However, if you are dealing with code written in the past
Inheritance can be used to continue to use <iostream. h> to maintain code consistency.

///////////////////

<Iostream> indicates that you are using the annotation namespace, that is, there should be such a sentence at the beginning of the program.
Using namespace std;
This follows the c ++ standard.
<Iostream. h>
The c ++ standard is not followed.
////////////////
<String. h> is the old C header file, which corresponds to a char *-based string processing function;
<String> the C ++ header file of std is packaged, corresponding to the new strng class;
<Cstring> is the std Version corresponding to the old C header file.

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.