如何构造/实例化对象std :: cout [英] How is the object std::cout constructed/instantiated
问题描述
所以std :: cout是一个对象。
谢谢。
它由 ios_base :: Init
构造。第一次创建对象时,会创建 cout
和朋友。如果最后一个对象被销毁, cout
和朋友被刷新(调用 .flush()
)。
在C ++ 0x中,如果你包含< iostream>
,并且使用 cout
和朋友之后 #include
将使用构造的 cout
在C ++ 03中,据说
构建对象,并且在第一次之前或期间的某个时间建立关联时间,构造类
ios_base :: Init
的对象,并且在任何情况下在主体开始执行之前。
So std::cout is an object. My doubt is how/where is it constructed/instantiated.
Thanks.
It's constructed by ios_base::Init
. First time that object is created, cout
and friends are created. If the last object is destroyed, cout
and friends are flushed (calling .flush()
).
In C++0x it will be guaranteed that if you include <iostream>
, and use of cout
and friends after the #include
will use constructed cout
and friends objects. In C++03, it is said that
The objects are constructed, and the associations are established at some time prior to or during first time an object of class
ios_base::Init
is constructed, and in any case before the body of main begins execution.
这篇关于如何构造/实例化对象std :: cout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!