Hi All ..

consider the case :

class test {

public :

int a;
test();

}


class test_derv : public test
{

public:
int a;

};


void main()
{

test * pctest = new test_derv;
delete pctest;
}

We have implicit destructors defined , when their actual definition is absent .
Does that mean , that when we delete a Base class pointer , pointing to a derived class , the actual memory assigned to the derived class is not released.

Is that a memory Leak ???

-varun

>We have implicit destructors defined , when their actual definition is absent .
No, since you declared the constructor, you're going to have to define it too, or else you're going to get linker errors.

>Does that mean , that when we delete a Base class pointer , pointing to a derived class , the actual memory assigned to the derived class is not released.
Yep.

>Is that a memory Leak ???
Yep. To fix the problem, look into [search]virtual destructors[/search].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.