Multiple choice technology programming languages

Which of the following describes the correct syntax for overloading new operator for arrays

  1. new operator cannot be overloaded

  2. void *operator new(size_t,int);

  3. void operator new;

  4. void *operator new;

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

The correct syntax for overloading new for arrays is void operator new. This returns a pointer (void) and takes size_t parameter. The [] indicates array allocation. Option C is incorrect because it returns void instead of void*. Option B is the scalar new overload syntax (no []). The new operator CAN be overloaded, including for arrays.