gpt4 book ai didi

c++ - 对象 std::cout 是如何构造/实例化的

转载 作者:太空狗 更新时间:2023-10-29 21:07:45 36 4
gpt4 key购买 nike

所以 std::cout 是一个对象。我的疑问是它是如何/在哪里构建/实例化的。

谢谢。

最佳答案

它由 ios_base::Init 构建.第一次创建该对象时,cout和 friend 被创建。如果最后一个对象被销毁,cout和 friend 们脸红了(调用 .flush() )。

在 C++0x 中,如果你包含 <iostream> 将得到保证, 和使用 cout和 friend 之后#include将使用构造 cout和 friend 的对象。在C++03中,据说

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.

关于c++ - 对象 std::cout 是如何构造/实例化的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4457795/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com