Possible Duplicate:
Can you print anything in C++, before entering into the main function?
Is there any possibility to run any other instructions before int main() is invoked?
int main(){cout<<"a";}
and before that call in main() there is call for cout<<“b”; somewhere before. Maybe this #define thing can help.
You don’t need a
define. Just create a global object (in the same file) and its ctor (or anything else you use to initialize it, such as calling a function) will run before main is invoked.Edit: likewise, those global objects will be destroyed after main exits, so their destructors will run at that time.