In the C ++ development environment, static member functions, like static data members, all belong to static members of the class and are not object members. Therefore, the reference to static members does not need to use the object name, but
Just beginning to learn C + + class and object parts, the class of constant data members and static data members of the concept and usage is often confused, so today to tidy up, by the way, today is my birthday, I wish my birthday happy, hehe.
In the process of C ++ object-oriented programming, data between objects is not shared. When designing a class, sometimes data shared between objects is required, in addition to setting the data to be shared as global data or functions, you can also
Static Data Member
When the data member declaration in the class is static, all instances of the class share the same Member, which is similar to the static variables in C functions. Static Data Generation
The Member is allocated to a fixed memory
① static members belong to the class, and non-static members belong to instances of the class.
② every instance of creating a class, the city in memory for the non static (dynamic) State members of the new allocation of a piece of storage;
Static
For static data member initialization, if it is in a multi-threading environment, you can initialize it using the following method:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
1
If
Today in using VS to make a DLL library, because if in a single-piece mode, a static pointer is declared in the. h file, the variable is defined in the corresponding CPP file. An error occurred while exporting:
Error 2error C2491: "Sdk_functions::p
In general, if there are N homogeneous objects, each object has its own data member, and the data members of different objects have their own values, which are irrelevant to each other. But sometimes people want to have one or several data members
in general, if there are N homogeneous objects, each object has its own data member, and the data members of different objects have their own values, which are irrelevant to each other. But sometimes people want to have one or several data members
Static Keywords of C ++
The static function of C ++ has two usage methods: static in process-oriented programming and static in object-oriented programming. The former applies to common variables and functions, and does not involve classes. The
Original blog, reprint please indicate the source--Zhou Xuewei http://www.cnblogs.com/zxouxuewei/Static is used in two ways: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables
The Static keyword in C1. Static local VariablesStatic local variables belong to static storage, which has the following characteristics:(1) A static local variable defines its lifetime as the entire program life cycle within a function, but its
Static is a common keyword in C + + that is used to control how variables are stored and visible.In a class definition, its members, including data members and member functions, can be declared as static members with the keyword static. The
Data members can be divided into static variables, non-static variables, two kinds.Static member: A member in a static class joins the static modifier, which is a statically member. You can access this static member directly using the class name +
Static
A static data type is used to create a permanent storage space for a variable. The statically variable keeps their values unchanged when invoked between functions. When used in a class, all the variables that are used in a static variable
The static of C + + has two usages: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables and functions, and does not involve classes; the latter mainly describes the role of
1. Static data members are declared in the class declaration and initialized in the file containing the class method. Initializes the class that the static member belongs to by using the scope operator. However, if the static member is a
Static data members of a class have different meanings from common static variables. They mean that each object of A Class shares a bucket instead of a bucket, all objects in this class can directly access the bucket. In fact, it is a variable
Static as the name implies. In this I would like to systematically tell about the role of the static keyword, of course, mainly to tell it in the development of language C and C + + role, in other aspects of the role please find additional
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.