The main. CPP
# include & lt; Iostream>
# include "Temp. H"
using namespace std;
Int main () {
Temp * Temp=new Temp;
The delete temp.
Temp=NULL;
Temp - & gt; Say ();
return 0;
}
Temp. H
# include & lt; Iostream>
using namespace std;
The class \ {
Private:
Int * a;
int length;
int top;
Public:
Temp () {
cout<" This is in Temp & lt; ""
Void say ();
~ Temp () {
cout<" Left Temp & lt; ""
};
Temp. CPP
# include "Temp. H"
Void Temp: : say () {
Printf (" Hello world \ n ");
}
Running result:
This is a Temp
Left Temp
Hello World
Why I can invoke the temp say after the delete () method??
CodePudding user response:
Because the temp memory area is not covered by the others, the delete it just tells the operating system, I applied for this memory I don't have to, this memory region still exist, use it until the next person and write other things,With disk a truth, you delete a file, only tell the operating system, I don't this paragraph of the content of the disk sector, this file will exist until the sector by others write data, that is why deleted files to restore and condition,
CodePudding user response:
Temp wasn't equal to NULL?Why can access to get?
CodePudding user response:
Temp wasn't equal to NULL?Why can access to get?
Temp: : say (no use) any member variables Temp, equivalent to a static function,
Call ((Temp *) NULL) - & gt; Say (), equivalent to a static function called Temp: : say ().
So there is no error,
If the Temp: : say () using the Temp member variables, a call would be AV errors,
CodePudding user response: