G
Gonçalo Rodrigues
Hi all,
I have a base class, call it Object, that implements operators new and
delete.
Now suppose there is also a class, call it Derived, deriving from
Object. It has the feature that *all* its instances are statically
allocated so I have to override new and delete.
Since *all* instances are statically allocated (and already fully
initialized by the time the program starts) I should just prevent
creation of objects from the heap by making operator new private. Is
this correct? And what about operator delete? Make it also private?
Or is there a "better way" (for suitable values of better)?
Best regards,
G. Rodrigues
I have a base class, call it Object, that implements operators new and
delete.
Now suppose there is also a class, call it Derived, deriving from
Object. It has the feature that *all* its instances are statically
allocated so I have to override new and delete.
Since *all* instances are statically allocated (and already fully
initialized by the time the program starts) I should just prevent
creation of objects from the heap by making operator new private. Is
this correct? And what about operator delete? Make it also private?
Or is there a "better way" (for suitable values of better)?
Best regards,
G. Rodrigues