C类静态变量的生命周期是多少?

前端之家收集整理的这篇文章主要介绍了C类静态变量的生命周期是多少?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我有一个叫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.

你明白了吗? 原文链接:https://www.f2er.com/c/113167.html

猜你在找的C&C++相关文章