Practice ยท 2 of 3
Prove the virtual destructor
Implement class Resource with a public virtual destructor and class HeavyResource : public Resource that acquires a resource in its constructor and releases it in its destructor. A helper int& leaked() (free function, function-local static) must count live HeavyResource objects. The test proves deleting through Resource* runs the derived destructor.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Polymorphism and the virtual destructor rule