c++ - Call a function before main -
possible duplicate:
is main() start of c++ program?
is possible call function before program's startup? how can work in c++ or c?
you can have global variable or static class member.
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 link - mirror of http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14 / proposed alternative - posted lundin.
Comments
Post a Comment