Which task does new perform that malloc does not?
-
A
It gives back a void pointer
-
B
It never reports failure
-
C
It allocates memory on the stack
-
D
It runs the object's constructor
Correct answer
Correct answer
D. It runs the object's constructor
15 views
Explanation
new allocates storage and then calls the constructor, which malloc never does.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ