G
george972
Hello,
This is a simple question for you all, I guess .
int main(){
double *g= new double;
*g = 9;
delete g;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<"
"<<endl;
*g = 111;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<"
"<<endl;
return 0;
}
The output:
4 8 8 9
4 8 8 111
Although I delete g, why is it that I can still use it and it
references to
actual memory?
The same happens when creating and deleting object types with new and
delete!
Please dont answer with what you think but with what actually happens.
If
you can point me to web sources I can read on this, it would have been
great!
Thank you in advance.
Regards,
This is a simple question for you all, I guess .
int main(){
double *g= new double;
*g = 9;
delete g;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<"
"<<endl;
*g = 111;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<"
"<<endl;
return 0;
}
The output:
4 8 8 9
4 8 8 111
Although I delete g, why is it that I can still use it and it
references to
actual memory?
The same happens when creating and deleting object types with new and
delete!
Please dont answer with what you think but with what actually happens.
If
you can point me to web sources I can read on this, it would have been
great!
Thank you in advance.
Regards,