If I have a class that contains private static data allocated on the heap that never changes, when, if at all, should I delete it?
As I understand it, a class itself is
static
data means, it persists the entire duration of the program.
However, if you use static
in pointer as:
static A *pA = new A();
then you can delete this, by writing delete pA
. But that doesn't invalidate my first statement. Because the object which is being pointed to by the static pointer is not static. Its the pointer which is static, not the object which is being pointed to by the pointer.