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.