The standard assert() macro tests its argument. If the result evaluates to 0, the standard abort() routine is called. Back in C heyday, it was a very useful debugging tool but it’s less so in C++. However, if you are using it in C++ code, please mind the following:
1. Since assert() macro exists only when the DEBUG symbol is defined (otherwise assert() collapses to nothing), it should never be used to test runtime errors such as failed connection, file not found, invalid input and the like.
2. When an assertion fails, abort() is called. This is dangerous, since destructors of local objects are not invoked in this case. Throwing an exception, on the other hand, ensures that local objects’ destructors are appropriately invoked.