I have a base class A and a derived class B.
class A
{
A();
virtual ~A();
void func1();
virtual void func2();
};
class B : public A
{
B();
~B();
void func2();
};
int main()
{
A* lBaseobj = new A ( );
lBaseobj->func1( );
lBaseobj = new B( );
lBaseobj->func2( );
delete lBaseobj;
return;
}
My question is: does delete lBaseobj frees the memory allocated to the lBaseobj object by new A( ) as well or not?
If you use smart pointers, memory will not be leaked: