I see often the following terms in C++ interview questions :
I'm not sure to see clearly the differences between those terms. Can someone provide a clear concise explanation?
Edit : the context question was : "What happens when you delete a pointer twice?" but knowing the differences between those terms is more important for me than just the answer.
These aren't really particular to C++.
Abort is when you terminate the program, or a particular operation, because of a problem. There is a C++ library function std::abort
, inherited from the C library, which kills the program as if by an external signal, and does not run destructors or clean-up.
An error is when something goes wrong. In C++, many kinds of errors are not necessarily detected immediately. C++ instead specifies undefined behavior, which may involve quiet memory corruption that may cause mysterious misbehavior later.
A failure is when a program does the wrong thing. This is pretty generic engineering term. The pointy-haired boss is probably more familiar with this concept than the others, because it's the only one a customer is really aware of.
A trap is when the program detects an error condition and takes some action accordingly.
So if you detect that the network went down, and show a message to the user such as "Could not continue; your document has been automatically saved" before quitting, then you have trapped an error and aborted, but nevertheless there was a failure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With