Executing code before main()

前端 未结 5 419
执念已碎
执念已碎 2020-12-03 03:15

In object-oriented languages (C++) you can execute code before main() by using a global object or a class static object and have their constructors run the code

5条回答
  •  醉梦人生
    2020-12-03 03:23

    There are portable ways of specifying functions that can be executed "after" main is executed.

    1. atexit()

    2. at_quick_exit()

    Further, follow this link and about various types of initialization in C++ - that may be useful for you to execute code before main() is called.

提交回复
热议问题