← Quiz: C++ Interview Questions: all 10 questions
Quiz: C++ Interview Questions · Question 5 of 10
What does new do that malloc doesn't?
What does new do that malloc doesn't?
- A.Allocates on the stack
- B.Calls the constructor and returns a typed pointer
- C.Frees memory automatically
- D.Nothing — they are identical
Answer & explanation
Correct answer: Calls the constructor and returns a typed pointer
new constructs the object; malloc only allocates raw bytes.
Can you get the rest right without peeking?
Take the timed Quiz: C++ Interview Questions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →