如果我有一个叫Test ::
class Test { static std::vector<int> staticVector; };
什么时候staticVector被构造,什么时候被破坏?
是否与测试类的第一个对象的实例化,或者就像常规静态变量一样?
只是为了澄清,在阅读“编程语言概念”(Sebesta Ch-5.4.3.1)之后,这个问题出现在我的脑海里,它说:
Note that when the static modifier
appears in the declaration of a
variable in a class definition in C++,
Java and C#,it has nothing to do with
the lifetime of the variable. In that
context,it means the variable is a
class variable,rather than an
instance variable. The multiple use
of a reserved word can be confusing
particularly to those learning the
language.
你明白了吗?