This is my program, it causes memoryleaks. I show only a small part where the problem exist. Starts with the header then the cpp.
ParticipatorRegister.h
#ifndef PARTICIPATORREGISTER_H
#define PARTICIPATORREGISTER_H
#include "Participator.h"
class ParticipatorRegister{
private:
Participator **arr;
int inc, init, elem;
void initiate();
//void expand();
public:
ParticipatorRegister();
~ParticipatorRegister();
//void save(ofstream&);
//void read(ifstream&);
//void add(string, string);
//void show(int);
//void showPaid();
//void showNotPaid();
//void findPerson(string);
//void alterInfo(string);
//void remove(string);
};
#endif
Participator.cpp
#include "ParticipatorRegister.h"
ParticipatorRegister::ParticipatorRegister(){
initiate();
}
void ParticipatorRegister::initiate(){
this->elem = 0;
this->init = 10;
this->inc = 5;
this->arr = new Participator*[init]; // Här sätter jag arr
}
ParticipatorRegister::~ParticipatorRegister(){ // Är denna rätt?
for (int i = 0; i < init; i++)
{
delete [] arr[i];
arr[i] = NULL;
}
delete [] arr;
}
I get this output from the debugger
Detected memory leaks!
Dumping objects ->
{117} normal block at 0x003960E0, 40 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The program '[0x9A4] misc.exe: Native' has exited with code 0 (0x0).
Can anyone see the problem and tell me what to do?