the following code produces a run time error. but i don't really understand How?
Code:#include <iostream>
using namespace std;
class ID {
int id;
public:
ID(int i) { id = i; }
void del() { delete this; }
int getID() { return id; }
};
int main()
{
ID id(10);
id.del();
cout << id.getID() << endl;
return 0;
}