It's your constructor which is the problem
> ptr = description;
You've already allocated memory, then copied it.
This just trashes that with a pointer to some memory you didn't allocate, so BOOM happens when you try and free it.
It's your constructor which is the problem
> ptr = description;
You've already allocated memory, then copied it.
This just trashes that with a pointer to some memory you didn't allocate, so BOOM happens when you try and free it.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.