Error handling (try catch)
Is there any way to catch or detect access violation error?
- QString *str;
should throw error, but it doesn’t.
The access violation error isn’t thrown (exceptions are thrown not errors) – it occurs when you access memory that you don’t own.
Anyway you can initialize your pointers with 0 (null pointer) and then first check for 0 and only then call a member-function (to be a little more safer you can assign 0 to the pointer after you delete it then you detect the attempt to call function after the pointer is deleted)