The new operator in C++ throws an exception of type _______ when it fails to allocate memory.
- invalid_type
- bad_memory
- bad_alloc
- new_failure
In C++, if the new operator fails to allocate the requested memory, it throws an exception of type bad_alloc. This is especially useful in situations where robustness is necessary, as it allows programs to handle memory allocation failures gracefully.
Loading...
Related Quiz
- The concept of Streams in C++ was introduced in the standard with _______.
- What will be the output of a loop if the continue statement is placed before the print statement inside the loop?
- When dealing with binary files, the ios::binary mode should be used in conjunction with another mode such as _______.
- How does friendship relation in C++ affect inheritance hierarchies, if at all?
- Which of the following scenarios is most suitable for using a struct instead of a class?