See StackOverflow on the answer, is the software upper (relative) components recommend the use of exceptions, low-level (relative) components recommend that the function return error code (if it is pure C, then the return error code is positive, the more independent module components, it is recommended to use the error code). Obviously, the return error code is relatively simple, but it will be difficult to maintain later on, and of course, it is not absolute.
Http://stackoverflow.com/questions/253314/exceptions-or-error-codes
Of course, this has to be a matter of opinion, not uniform bias with one. Here are a few community discussions that are better discussed:
http://www.iteye.com/problems/59997
http://star.baidu.com/forum/forum.php?mod=viewthread&tid=412
How to use C + + exceptions:
http://blog.csdn.net/renwotao2009/article/details/6751687
Of course, the exception has a very obvious benefit, that is, the caller of the function will not forget the check return value. Because there is no need. If you simply return the error message, what if the return value is not checked? Then once the error occurs, the program will continue to run and enter an indeterminate state.
Design principle-----function returns an error or throws an exception