Systematically Starting and Stopping Software Objects
摘要
In Chapter 2 , you began exploring OOP using C++ language to model a variety of real-world applications and gaming applications related entities. This chapter explains how to handle the important startup and shutdown activities of software in a systematic approach using C++ constructors and destructors. Constructors are special member functions of a class that are executed automatically when objects of the class are created. Developers use constructors for defining and conforming all major startup sequence activities, such as initialization, configuration, resource allocation, and startup sequence-dependent services. On the other hand, destructors are other special member functions of a class, they get executed when class objects get deleted. Developers use destructors for carrying out activities such as gracefully releasing resources, closing files, and closing services. C++ constructors and destructors greatly simplify debugging activities related to pinpointing software startup and shutdown issues.