|
-
Dec 3rd, 2002, 12:51 AM
#1
Thread Starter
Lively Member
URGENT : C++ destructor problem !! plss help
hello friends ,
I have written a C ++ code
Here the destructor isnt dereferencing after the " delete " operator .
Plss just check the code and plss tell me whass worng in it ?
Why isnt the destructor dereferencing after the delete operator ?
Here's the code below
#include <stdlib.h>
#include <iostream>
using namespace std;
class hello{
int *num ;
public : void trip();
public :
//constructor
hello()
{
num = new int;
cout<<"hello !! world\n";
*num = 20;
cout<<*num<<endl;
}
//destructor
~hello()
{
delete num;
cout<<"deleting"<<endl;
cout<<*num<<endl;
}
};
void hello:: trip(){
cout<<"hello again"<<endl;
cout<<*num<<endl;
}
//main file
int main(int argc, char *argv[])
{
hello *hh = new hello ;
delete hh;
hh->trip();
flush;
return 0;
}
waiting for reply
Prasad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|