Escolar Documentos
Profissional Documentos
Cultura Documentos
Exceptions
Exceptions are error that occur at run time There may be many reasons for occurrence of exceptions Falling short of memory Inability to open a file Exceeding the bounds of an array Attempting to initialize an object to an impossible value
Example
class sample { public: // exception class class errorclass { }; void fun() { if( some error occurs) throw errorclass(); // throws exception } }; // application void main() { // try block try { Sample s; s.fun(); } catch( sample:errorclass) // exception handler or catch block { // do something about the error cout<< You are Idiot; }