Page 1 of 1

Memory leak

Posted: 27 Jan 2016, 11:50
by dex123
De ce imi da la rulare memory leak in aceasta secventa?


Constructor cu parametri
Cladire(int an, char *loc, float p, int n, int *v) : anConstructie(an)
{
this->localitate=new char[strlen(loc) + 1];
strcpy(this->localitate, loc);

pret = p;
nrCam = n;
vectorSuprafata=NULL;
setVectorSuprafata(v, n);
}

Re: Memory leak

Posted: 27 Jan 2016, 16:05
by Viorel
Probabil ai uitat de destructor:

Code: Select all

~Cladire()
{
    delete [ ] localitate;
    localitate = nullptr;
}