[C ++] smart pointer reference count of how to achieve? - all objects of that class share static class member variable

Q: smart pointers can refer to the number of pointers is counted when a smart pointer release, other smart pointers how do you know?

This is a trick question title. . . .

Unlike ordinary variables, static member variables are shared by all class objects, different object can access the other side of the static member variables, static member variables and class objects are not linked.

The static keyword has another meaning when applied to global variables -- it gives them internal linkage (which restricts them from being seen/used outside of the file they are defined in). Because global variables are typically avoided, the static keyword is not often used in this capacity.
Unlike normal member variables, static member variables are shared by all objects of the class.Static members are not associated with class objects

Guess you like

Origin www.cnblogs.com/dylanchu/p/11616369.html