C ++ namespace

Source: Internet
Author: User
STD namespace in C ++[16:12:10] font size: used before the Standard C ++ for both large and small sizes # include <iostream. h> This is written because the header file name to be included is iostream. h. Standard C ++ introduces the concept of namespace, and encapsulates the stuff in the standard library such as iostream into the STD namespace. In order not to be confused with the original header file, it is stipulated that the standard C ++ should use a new set of header files without adding the names of these header files. h extension, such as iostream and string, and rename the header file of the original C standard library, such as the original string. H is changed to cstring (that is,. h removed, followed by the letter C), so the header file contains the statement # include <iostream>.
You must use using namespace STD instead of # include <iostream>; the reason we usually write this is to expose all the stuff in the STD namespace to the global domain (like directly including iostream. h) makes the Standard C ++ library use the same as the traditional iostream. h. If you do not need using namespace STD, you must always include the full name of the namespace, such as STD: cout <"hello" <STD: Endl;
# Include "iostream" and # include <iostream> are different: the former first finds the iostream file in the current directory, and then finds the system header file path. The latter is the opposite. Therefore, as a good habit, try to use <> when containing System header files, and use "" when containing header files in your project "".

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.