Let's talk about static variables and static functions in C. (1) static variables in C are stored in the global storage zone, which is different from automatic variables stored in the stack. The key difference between the two is their scope. The
C LanguageMemory is required to store data. The memory is mainly divided into two types: static storage area and dynamic storage area;
1.Static storage ZoneIt can be divided into read-only data, RW data, and uninitialized data (BSS ). They
A static member is a member of a declared static class. All objects in the class share data. Youyuan is a common function defined outside the class, but it needs to be explained inside the class. In order to distinguish it from the member function
is looking at the Google C + + programming specification, the inside of the enemy file dependency is said:Use the predecessor Declaration (forward declarations) to minimize the number of # include in. h files. When a header file is included, a new
Summary of the use of C + + static member variables and static member functions:
one. Static member Variable:A data member in a class body is preceded by a static keyword, and the data member becomes a statically data member of the class. As with
Undefined reference to * * * The link error pattern is always endless (more), this time is not found in the class members.
Example 1:undefined reference to VS. Class static member variable
Class A and Class B are declared in file A.h:
Class A
{
Scope and visibility of identifiers
A scope is an area in which an identifier is valid in the body of the program.
Scope classification
Function prototype scope
Local scope (block scope)
Class scope
File scope
A static member function is a member function of a class that does not belong to any object of the class request, but is a function shared by all members of that class.For example, you have 10 people in your class (10 for Class one by one), and the
C ++ basics, important technologies, and basic technologies1. Implementation of class and object 1.1
The first method is to define the member functions of the class in the class body.The second method is to place the implementation of the member
STL cross-platform calls may encounter many exceptions. You can try it.
STL uses the template generation. When we use the template, every EXE and DLL generates their own code in the compiler, causing the static members used by the template to be
In C ++, memory is divided into five areas: heap, stack, free storage, global/static storage, and constant storage.
Stack is the storage area for variables that are automatically allocated by the compiler when necessary and clear when not needed.
1. In C ++, memory is divided into five areas: heap, stack, free storage, global/static storage, and constant storage.Stack,It is the storage area of variables that are automatically allocated by the compiler when necessary and clear when not needed.
1.Base class and derived class:
When a class is derived from another class, the original class is called the base class, And the inherited class is called the derived class. The basic syntax is: Class subclassname: Public baseclassname {}; Public
In C and C ++, s t a t I c has two basic meanings, and these two meanings often conflict with each other:
1) allocated on a fixed address, that is to say, the object is created in a special static data zone, instead of being generated on the stack
Five memory partitions
In C ++, memory is divided into five areas: free storage, global/static storage, and constant storage.
Stack is the storage area for variables that are automatically allocated by the compiler when necessary and clear when not
3.7.1 data member
Example 3-35
This example illustrates the syntax for declaring static members. The data member N of the task class is related to the task class and has nothing to do with any task object. Since N is static and static, it only has
Class static members are mainly used to solve the problem of resource sharing. However, it is still quite cool to use, and it is easy to mix up, so write it here
For later use. Class static members include static data members and static function
In C ++, memory is divided into five areas: heap, stack, free storage, global/static storage, and constant storage.Stack is the storage area for variables that are automatically allocated by the compiler when necessary and clear when not needed.
18 key notes for C ++ Primer Plus 6th, primerplus
The following are the notes I have taken after reading C ++ Primer Plus version 6th, which can be used as a memorandum for future review.Note Section
Why is the const of C ++ better than that of C #
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.