#include #include #include "announcer.h" using namespace std; announcer *a[] { //an array of 3 pointers nullptr, nullptr, nullptr }; void constructObjects(); //function declarations void destructObjects(); int main() { constructObjects(); cout << "\n"; cout << announcer::howMany() << " objects exist at this point.\n\n"; destructObjects(); return EXIT_SUCCESS; } void constructObjects() { //Construct 3 objects in 3 separate blocks //of dynamically allocated memory. a[0] = new announcer {10}; a[1] = new announcer {20}; a[2] = new announcer {30}; } void destructObjects() //in a different order { delete a[1]; //no [], because we're deleting one object, not an array delete a[0]; delete a[2]; }