I don't really understand the advantages with the try-catch-throw statements. I took a look at msdn explanation of the statements and here's an example they've given:
If I would have done the same thing I would have written:Code:int main() { char *buf; try { buf = new char[512]; if( buf == 0 ) throw "Memory allocation failure!"; } catch( char * str ) { cout << "Exception raised: " << str << '\n'; } }
I don't really se the difference and my is much more compactCode:int main() { char *buf; buf = new char[512]; if (buf == 0) { cout << "Memory allocation failure!\n"; cout << "Exception raised: " << str << '\n'; } }



LinkBack URL
About LinkBacks



