I have the following code and was wondering if it is a memory leak
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
template <class T>
class live {
vector<T> _data;
live<T> *_next, *_temp;
public:
live(int elements, int chunk = 10) : _next(NULL)
{
if (elements > chunk)
{
_data.reserve(chunk);
_next = new live<T>(elements - chunk, chunk);
}
else _data.reserve(chunk);
}
~live() { if (_next) { _next->~live(); delete _next; } }
};
Do I have to call the destuctor of the vector because I allocated:
_next = new live<T>(elements - chunk, chunk);
or is it called automatically when it becomes out of scope?