Hi guys, what is the deference between ASSERT macro and Exception handling in cpp

Recommended Answers

All 2 Replies

The two aren't related. Assertions are for catching bugs in the code, exceptions are for managing legitimate errors when the program runs.

assert(expr);
if expr evaluates to true, then OK
else
if in debug mode - calls abort
else - does nothing but this is probably bad

one can use BOOST_VERIFY which is basically like assert, but works in release mode too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.