K
Kannan
Some amount of memory is allocated inside the Base Constructor using
new. During the construction of a derived object an exception occurred
in the constructor of the derived class.
Will the memory get de allocated which got allocated in Base class
constructor? Will the Base class destructor get called?
class Base
{
int *p;
public:
B() { p = new int[100]; }
~B() { delete[] p; }
};
class Derived : public Base
{
public:
Derived ()
{
/* Exception Occurred!!!!!!!!!!!!! */
}
};
new. During the construction of a derived object an exception occurred
in the constructor of the derived class.
Will the memory get de allocated which got allocated in Base class
constructor? Will the Base class destructor get called?
class Base
{
int *p;
public:
B() { p = new int[100]; }
~B() { delete[] p; }
};
class Derived : public Base
{
public:
Derived ()
{
/* Exception Occurred!!!!!!!!!!!!! */
}
};