Please have a look at below sample code:
In above I created object "t" and destroyed using delete operator.Code:#include<iostream.h> class Test { public: void fun() { cout<<"In fun"<<endl; } Test() { cout<<"In const"<<endl; } ~Test() { cout<<"In dest"<<endl; } }; int main() { cout<<"Hello"<<endl; Test * t = new Test(); t->fun(); delete t; t->fun(); return 0; }
After destroying also I am able to call the function "fun".How it is possible
output of above code :
Hello
In const
In fun
In dest
In fun
If i am able to call the function , than what actually destruction will do ?




Reply With Quote