A
ambar.shome
Hi,
See this code snippet....
class base1
{
public:
~base1(){cout<<"base1 destructor called"<<endl;}
};
class base2
{
public:
~base2(){cout<<"base2 destructor called"<<endl;}
};
class derived: public base1, public base2
{
public:
~derived(){cout<<"derived destructor called"<<endl;}
};
void main()
{
base2* b2 = new derived();
cout<<"Ambar in UNIX"<<endl;
delete b2;
}
When I executed this on a Solaris machine and it has given following
output:
"base2 destructor called"
but when i tried to execute it has given me run-time error.
at "delete b2".
Can anyone tell me the reason of this type of behaviour of C++?
See this code snippet....
class base1
{
public:
~base1(){cout<<"base1 destructor called"<<endl;}
};
class base2
{
public:
~base2(){cout<<"base2 destructor called"<<endl;}
};
class derived: public base1, public base2
{
public:
~derived(){cout<<"derived destructor called"<<endl;}
};
void main()
{
base2* b2 = new derived();
cout<<"Ambar in UNIX"<<endl;
delete b2;
}
When I executed this on a Solaris machine and it has given following
output:
"base2 destructor called"
but when i tried to execute it has given me run-time error.
at "delete b2".
Can anyone tell me the reason of this type of behaviour of C++?