Now suppose I have a pointer to an object and this object is deleted by another thread or earlier in the program inadvertently. Not really important why.
What kinda of exception is raised if the pointer points to a deleted object and a method is called on this object.
class CSample
{
public:
void DoSomthing()
{ . . . . . }
};
void main()
{
CSample * sample = new CSample;
. . . . .
delete sample;
. . . . .
try
{
sample->DoSomething();
}
catch(...)
{
//handle invalid reference
}
. . . .
}
while this will work. I would rather only capture the fact that this pointer is no longer valid. So what should go in in place of the ...?