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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -