Can you print anything in C++, before entering into the main function?
It is interview question in Bloomberg:
Answer :create a global varia
Header file
class A { static A* a; public: A() { cout << "A" ; } };
Implementation file:
A* A::a = new A;
Well, statics (and not only) are initialized before the call to main.
main
EDIT
Another one:
bool b = /*(bool)*/printf("before main"); int main() { return 0; }