C ++ storage modifier explanation zosatapo (original)

zhaozj2021-02-16  57

C storage modifier interpretation (pure theoretical part) In C , storage space is primarily referred to as a variable or function or class (hereinafter, for convenience of applying an identifier). To this end, C provides the following storage space modifications, which tells the compiler identifier's survival cycle and seeability (which can be understood as a reference), and how these identifiers should be stored. Survival Space Modifier: AutoregisterStaticextern This article is divided into several parts, each of which is relatively independent. /// Link (Linkage) //// [Important] Defines how an identifier is referenced here. I first explain the concept of links. This concept has an important effect on some of the other concepts in this article. The link refers to the identifier that declares in different living spaces or declares that multiple times in the same living space is actually pointing to a common memory space (such as variables or functions). Linkage defines whether an identifier can be referenced in different parts of the program ("also" visible "). The link in C can be divided into three categories: internal, external, and no linkage. /////////////////////////////////////////////////////bit We said that this identifier is Internal Linkage. Otherwise, let's say this identifier is External Linkage. //// / External Linkage /// Inframe (Variable or Function) in the file survival space (FileScope), we say that this identifier is ExternalLinkage. Although we should explicitly use the storage modifier extern, the external linkage flag is declared, but because the default case is ExternalInkage, we can provide Extern modifiers without explicit. / //// no linkage /// If the identifier is declared in a block (block), without the extern storage modifier modification, we say this identifier is no linkage, and this identifier is only to this area. The block is visible. // Survival Space and Visibility /// (Scope and Visibility) // [Important] Defining Variables I will actually exist first before the part of the program file is made. The vast universe is so mysterious for us, we can say that things are all in the earth, haha. At least we can think in mind. Because object objective existence is there, do not belong to any individual and group. But do we say that these words make sense? In fact, there is no meaning, just a phenomenon I told. Haha, let's turn this topic again. Although the objects in the vast universe are not part of any individuals and groups, can everyone take it? A simple example you have to go to the moon? no! ! But some people have been there because they have better tools (you can think they have higher privileges). It's so pulled, saying that the phenomenon is here, and it is officially started our topic. The "visibility" of the identifier determines which parts we can can reference in the program.

转载请注明原文地址:https://www.9cbs.com/read-27986.html

New Post(0)