1. It's not "Strenght" and "Lenght". it's "Strength" and "Length".
2. According to what you've written in your pastie, there should be no memory leaks. We need more code in order to see the source of memory leakage.
If there are memory leaks there, they are caused by your exercise classes. Do you dynamically create objects inside your exercise class that you don't delete in the destructor?
I didn't see anything that would leak (short of throwing an exception). Are you sure you're using the leak check thing right? It doesn't require another line at the end of the program?
Consider running it through valgrind.
EDIT:
...actually, you're right. You're deleting the object through a base class pointer. You need a virtual destructor to do that.
...actually, you're right. You're deleting the object through a base class pointer. You need a virtual destructor to do that.
Added a virtual destructor to every class,and voila,no memory leaks!
The reason i didnt go with em in the first place,is cause i thought you didnt need a virtual destructor unless you allocate new memory in the constructor. Think i did misinterpret
that having a empty destructor=no destructor at all.
,is cause i thought you didnt need a virtual destructor unless you allocate new memory in the constructor
You need a destructor when you need to free resources you have allocated (probably in the constructor)
It needs to be virtual when someone will do this:
1 2
Base* p = new Derv(some_handle);
delete p;
Since it is virtual, it will correctly call ~Derv(), if it wasn't it will only call ~Base(), thus never releasing some_handle.
Obviously this only applies if you want someone to be able to derive from your class. If you look at the STL containers, you will notice they don't have virtual destructors. That is because they aren't meant to be derived from.