ObjDef.h
/* * * Date: 2019.09.07 * */ #ifndef _H_H_OBJ_DEF_H_H_ #define _H_H_OBJ_DEF_H_H_ #include <iostream> class ObjA { public: ObjA() { std::cout << "Construct ObjA" << std::endl; } ~ObjA() { std::cout << "Destruct ObjA" << std::endl; } }; class ObjB { public: ObjB() { std::cout << "Construct ObjB" << std::endl; } ~ObjB() { std::cout << "Destruct ObjB" << std::endl; } }; class ObjC { public: ObjC() { std::cout << "Construct ObjC" << std::endl; } ~ObjC() { std::cout << "Destruct ObjC" << std::endl; } }; #endif
main.cpp
/* * * Date: 2019.09.07 * */ #include <iostream> #include "ObjDef.h" ObjA a; ObjB b; ObjC c; int main() { std::cout << "Hello World" << std::endl; return 0; }
Results of the
in conclusion:
Global object initialization sequence and the opposite sequence destructor.
May be performed in a data structure stack appreciated advanced after the first call initialization, after calling the destructor.
Local object initialization sequence destructor, consistent with the global object.