Thinking: Each variable has properties. Are there some attributes that are owned by all objects?
1. Static member variables
1) defining static member variables
Ø keyword static can be used to describe a member of a class,
Static members provide a shared mechanism for a homogeneous object
Ø when a member of a class is described as static, this class, regardless of how many objects are created, share this static member
Ø static member belongs to class, it is not an object member
2. Static member functions
1) Concept
Ø static member function number is prefixed with the keyword static
The static member function provides a common operation that does not depend on the class data structure, and it does not have this pointer
Ø call a static member function outside the class with a "class name::" As a qualifier, or through an object call
Problematic: Static member functions cannot use normal variables.
A static member variable belongs to the entire class, which is not clear, and is the property of that specific object.
Summary: Static modified member variables belong to the class itself, ordinary member variables belong to the object, how many objects will have the corresponding member variables, static member variables are common.
Static functions that are part of the class itself are not allowed to access non-static variables! Static functions can be accessed through object access or through the class name.
The above is the C + + review points summary of the five static member variables and member functions of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!