This question already has an answer here:
I am not getting run time exception/error on below code. I called the member function Display() after destroying the object. Then why it still calls the function Display instead of compiler error? I am using Dev C++ ide.
Thanks in advance.
#include< iostream>
#include< string>
using namespace std;
class Sample
{
int count ;
public:
void Display()
{
cout << count << endl;
cout << "Inside Sample::Display" << endl;
}
};
int main()
{
Sample *ob = new Sample();
delete ob;
ob->Display();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire