I am creating a c++ object with two slightly different ways, in the following code when CASE is 0 there is a memory leak, but no memory leak in the else case.
A couple of months ago I asked this question where I asked why there was a memory leak. Apparently, I forgot a virtual destructor.
I'm using valgrind to check for memory leaks. Unfortunately I get a Leak_DefinitelyLost warning.Attached is a simplified version of my code that reproduces the error:
In C++14 (gcc 6.3) I have the following code:When running valgrind i have a memory leak : it looks like the objects created by "makeB()" function were not freed. I had this problem only when using aggregate initialization with curly braces.
I am C novice but been a programmer for some years, so I am trying to learn C by following along Stanford's course from 2008 and doing Assignment 3 on Vectors in C.