Does the following code produce undefined behaviour?
Im talking specifically about the the constructor of X which uses std::cout. cout and "static X x" are both global objects and class X uses cout in its constructor before main is entered. In other words, can I always depend on cout being constructed properly before use?Code:#include <iostream>
class X
{
public:
X() { std::cout << "X" << std::endl;
};
static X x;
int main()
{
X x2;
return 0;
}