You can have a global variable or a static class member.
static
1) static class member
//BeforeMain.h class BeforeMain { static bool foo; }; //BeforeMain.cpp #include "BeforeMain.h" bool BeforeMain::foo = foo();
2) global variable
bool b = foo(); int main() { }
Note this link - Mirror of http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14 / proposed alternative - posted by Lundin.
2.1m questions
2.1m answers
60 comments
57.0k users