This can be illustrated by the following program:
#include <iostream> using namespace std; class Component { public: ~Component(void); }; class Whole { Component c1, c2; public: ~Whole(void); }; Component::~Component(void) { cout << "A Component is destroyed" << endl; } Whole::~Whole(void) { cout << "A Whole is destroyed" << endl; } int main(void) { Whole w; return 0; }