加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 05:58:52 所属栏目:百科 来源:网络整理
导读:如果我有一个叫Test :: class Test{ static std::vectorint staticVector;}; 什么时候staticVector被构造,什么时候被破坏? 是否与测试类的第一个对象的实例化,或者就像常规静态变量一样? 只是为了澄清,在阅读“编程语言概念”(Sebesta Ch-5.4.3.1)之后,这
如果我有一个叫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.

你明白了吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读