C + + contains header files when angle brackets and double quotation marks differ

Source: Internet
Author: User

Original link: http://c.biancheng.net/cpp/biancheng/view/66.html

If you are looking at some other C + + tutorials, you may have discovered early on that some of the book's # include commands write # include < filename, but sometimes the # include "FileName" appears. You will wonder, which one is right? Why do they have to be written in two different ways?

Both of these are the correct wording, but they are different. We know that C + + already has some well-written header files (such as standard libraries, etc.) that are stored in VC + + 's include folder. When we use the # include < file name > command, the compiler goes to this folder to find the corresponding file. Obviously, using this notation to include a header file that we wrote ourselves (not in the Include folder) would make a mistake. Therefore, you should use angle brackets when you include header files that are provided by C + +.
Conversely, #include the "file name" command is to search for a matching file in the same directory as the current file, or to find the corresponding file in the Include folder. Therefore, whether the file is provided by C + + or written by itself, using the # include "file name" command must be correct. This is why the program before this section of the book uses the # include "file name" command.

about the standard angle brackets
In the latest C + + standard, the header file included with C + + is not a write # include < filename, and the notation of # include <iostream.h> is obsolete. The correct notation is # include <iostream> and use the Std namespace. Some programs have a using namespace std, which is written according to this standard. Namespaces are also called namespace, and are primarily used to avoid glyph collisions in large program development. The standard also specifies how to include C header files in C + +, and interested readers can access the information online.


Although both of these # include commands can be correctly identified by VC + +, they do not conform to C + + standards. standard specifies that you should use angle brackets when you include standard header or system header files that are provided by C + +, and you can use double quotation marks when you include a custom header file. Since it has been explained here how to include a header file by standard, in subsequent chapters, the # include command for all programs will be written according to the standard.

Try:
If you include a header file when writing such as # include &LT;IOSTREAM&GT, but there is no using namespace std, that is, if you do not use the Std namespace, can the normal implementation of input and output functions?
Conclusion: If you follow this notation, you must use the STD namespace.

C + + contains header files when angle brackets and double quotation marks differ

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.