Memory leak

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++
Post Reply
dex123
Junior
Junior
Posts: 1
Joined: 27 Jan 2016, 11:46

Memory leak

Post by dex123 » 27 Jan 2016, 11:50

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);
}



Viorel
Microsoft MVP
Microsoft MVP
Posts: 292
Joined: 13 Jul 2007, 12:26

Re: Memory leak

Post by Viorel » 27 Jan 2016, 16:05

Probabil ai uitat de destructor:

Code: Select all

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

Post Reply