I have a class but I want to create a static member of the class, so the objects can exchange data throught it. The member must be a dinamic char*, so I can pass strings through it, but the problem is how to 'delete' the dinamic memory, which I have alocated when there are no more objects?
The only one sollution that I could think out was to have another one static variable, which counts the instances of the class and when the counter reaches 0, then I delete the memory in the destructor of the class.
I wonder is any other way to manage static variables? And is there any way to do it in the end of the program no matter if there are 'live' objects?