"C ++ Primer Third Edition" Reading Notes - Chapter 8 Domain and Life

zhaozj2021-02-16  199

1. The domain (Scope) is a general context used to distinguish the meaning of the name (CONTEXT).

2, the process of name resolution is the process of associating a name field in the expression in the expression, but also the process of giving this name.

3. Because the order in which the field is found during the name resolution, the declaration in the peripheral domain is hidden by the same name in the nested domain.

4. Keyword Extern provides a way for a statement but does not define an object. It is similar to a function declaration, promises that the object will be defined elsewhere, or elsewhere in this text file, or in other text files of the program. Such as:

Extern INT I;

There is a keyword extern, but also specifying a global object declaration of an explicit initial value will be considered as definition of the object.

5. Symbol constants can be defined multiple times in different files of the same program.

6. Uninitialized auto objects contain a random bit mode, which is the result of the last used, which is called unconfigured.

7, New Expression Call Library Operator New (), DELETE Expression Call Library Operator Delete ().

8. If the pointer operand is set to 0, C will ensure that the DELETE expression does not call operator delete ().

9. The first dimension of the dynamically assigned array does not have to be constant.

10. Create a const object in an idle storage area with a New expression:

Const Int * PCI = New Const Int (1024);

11. To use the location new expression (Placement New Expression), you need to include the header file

. This facility allows programmers to allocate a large amount of memory for use in this form of New Expression to create an object. Such as:

TestClass * Pb = new (buf) TestClass; // do something elsedelete [] buf;

Where BUF is defined before, such as:

Char * buf = new char [5120];

When using Delete, not

Delete PB;

But must be

DELETE [] BUF;

12. The namespace did not eliminate the global name spatial pollution, but it greatly alleviated this problem.

13, :: MEMBER_NAME Points member MEMBER_NAME for global namespace.

14. Only the namespaces that are surrounded by members (the namespace where the member and its peripheral name space) may contain it. Only one namespace member has declared in the namespace definition, it can be defined outside of the namespace definition. When the namespace member is defined outside the namespace, the return value of the namespace name and function must be defined.

15. The definition of unnamed namespace is partially in a specific file.

16. Simplify the usage of the namespace member: Namespace alias, using declaration, using indicator.

17. The name space introduced by using statement has the following characteristics:

It is uniquely introduced in this domain to the same name introduced by the declaration in the peripheral domain being hidden by it hides the same name in the nested domain.

18, the USING indicator makes the namespace member visible, as if they are declared outside the name space being defined.

19. Use using declaration instead of the USING indicator to better control the global namespace pollution problem.

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

New Post(0)