E
ES Kim
MEC++ Item 17 explains how to require an object be constructed only
on heap. No automatic, no static objects, that is. But I can't
find how to enforce the requirement for derived classes too.
1. make the base destructor private
No class can be derived from the base. Game over.
2. make the base destructor protected
Derived destructors should be also protected to meet the requirement,
but all bets are off once you forget to declare explicit destructor.
(It's the way most of us do most of the time.)
Any suggestion to enforce the requirement?
on heap. No automatic, no static objects, that is. But I can't
find how to enforce the requirement for derived classes too.
1. make the base destructor private
No class can be derived from the base. Game over.
2. make the base destructor protected
Derived destructors should be also protected to meet the requirement,
but all bets are off once you forget to declare explicit destructor.
(It's the way most of us do most of the time.)
Any suggestion to enforce the requirement?