Memory Model and namespace of C ++ Primer, primer Model

Source: Internet
Author: User

Memory Model and namespace of C ++ Primer, primer Model
C ++ Primer Memory Model and namespace 1. header file

Header files include: function prototype; Use # define or const-defined symbolic constants; Structure Declaration; Class Declaration; template declaration; Inline Function

// Avoid multiple inclusion of the consent header file # ifndef COORDIN_H_EXAM # define COORDIN_H_EXAM... # endif
2. Storage continuity, scope, and connection

Link: how the name is shared among different units.

Automatic Storage Persistence: variables defined in the function (including parameters); Scope: local code blocks; connectionless (stack) static storage persistence: variable defined outside the function and variable defined by the static keyword thread storage continuity (C ++ 11): keyword thread local Declaration (same length of life cycle and thread) Dynamic Storage continuity: keyword new declaration (HEAP)

Three Links for static storage persistence variables:

External link (accessible in other files): external Declaration of the code block (no static) Internal Link (accessible only in the current file ): the code block is declared connectionless with static outside (only accessible in the current code block): the code block is declared with static.

3. namespace
Namespace exam {// declare variables, function prototype, structure class declaration} // cannot be located in the code block using namespace exam; using exam ::...; // nested namespace t1 {using t2 ;...}

Related Article

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.