Multiple choice

What is/are the advantage(s) of using new operator over malloc() in C++?

  1. malloc() is not used in C++.

  2. malloc() is type-safe but new is not type-safe.

  3. malloc() only allocates memory, while new operator allocates memory as well as constructs objects in C++.

  4. Both (2) and (3)

  5. None of these

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

Yes, this is the main advantage of using new operator over malloc() in C++.