Multiple choice

When will the bad_alloc exception be thrown by a program?

  1. Thrown by pointer on allocation failure

  2. Thrown by new operator on allocation failure

  3. Thrown by wrong allocation of data type

  4. Thrown by cin and cout

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

When we are allocating the memory using new operator and allocation fail, then bad_alloc exception is thrown by the program.