Exceptions in c ++ exception handling (Weng Kai c ++ class disclosed in [36])

Exceptions for processing Run-time Error;

// exception trapping pseudocode file read 
the try {
    open the file;
    determine its size;
    allocate that much memory;
    read the file into memory;
    close the file;
}catch(fileOpenFailed){
    doSomething;
}catch(sizeDeterMinationFailed){
    doSomething;
}catch(memoryAllocationFailed){
    doSomething;
}catch(readFailed){
    doSomething;
}catch(fileCloseFailed){
    doSomething;   
}

 When an exception is thrown, so that the function has found the problem itself can not handle an exception

Guess you like

Origin www.cnblogs.com/go-ahead-wsg/p/12150226.html