The relationship between C + + namespaces and header files, for example, has been used by #include<string>, and why is the using std::string?

Source: Internet
Author: User

(1) if a C + + program uses a header file with the suffix ". h", then you do not have to declare the namespace in the program, only the file contains the header file, (2) the C + + standard requires the system to provide a header file without the suffix ". Instead of using the suffix ". h" in the header file, prefix c with the corresponding header filename in C:

(3) Custom header file usually with suffix ". h", System standard library file without suffix ". h".

(4) because the standard library is very large, the programmer in the choice of the class name or function name is likely to be the same name in the standard library. So in order to avoid the name conflict caused by this situation, all the H identifiers in the standard library are placed in the namespace Std.

(5) Answer: If you do not use the using std::string, you use the string type variable in your program, and the program does not recognize a string variable in the standard library. A string variable may also be included in the program customization header file. So be sure to declare the using std::string. The string variables inside the program are all string variables in the STD standard library.

The relationship between C + + namespaces and header files, for example, has been used by #include<string>, and why is the using std::string?

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.