c++ 中 local static 对象何时被初始化
2010-09-09 15:50
155 查看
在VS2010中,可以发现,对于primitive type, local static对象在首次调用所在函数是已经初始化完毕,实际上应该在main函数前已经初始化完毕,但对于user defined type(class),其初始化函数是在首次调用所在函数时进行的
class A{ public: A(int t){ cout << "called from A: constructor" << t << endl;} protected: int a; char b; }; void local() { static int c = 10; static A a(3); } int main() { local(); return 0; }
相关文章推荐
- C++ local static对象和non-local static对象在初始化时机上的差异
- C++转Java自学之路(四)文档注释、静态代码块与对象初始化过程
- C++入门学习:对象初始化列表
- C++对象初始化
- local static对象和non-local static对象在初始化时机上的差异
- c++中对象初始化
- C++使用构造器初始化对象的两种方式
- 读书笔记_Effective_C++_条款四:确定对象被使用前已先被初始化
- [C++再学习系列] 全局或静态变量(对象)的初始化
- 【C++】派生类对象初始化基类的引用
- [C++]对象初始化 / 构造函数
- 让我们来看一看C++ 二.对象的定义、初始化和赋值
- C++构造与析构(18) - 静态对象(static object)何时销毁
- C++对象初始化
- Effective C++ Item 04-确定对象被使用前以先被初始化
- C++ 与“类”有关的注意事项总结(十):类对象数组初始化(三种方法)
- C++找对象的季节——构造函数初始化的三角形类
- C++构造与析构(18) - 静态对象(static object)何时销毁
- C++学习——静态对象的初始化问题
- 【C++】初始化模板参数对象(zero initialization)