Cyber Monday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 1 Question 24 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 24
Topic #: 1
[All CPA-21-02 Questions]

Which line of code inserted instead of the comment will make the following code run properly without causing memory leaks?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Ty
2 months ago
I believe option B is incorrect, some code is needed to properly manage memory.
upvoted 0 times
...
Kina
2 months ago
I'm not sure, but I think option C might also work since it deletes ptr twice.
upvoted 0 times
...
Avery
2 months ago
I agree with Jospeh, option D makes sense to prevent memory leaks.
upvoted 0 times
...
Jenise
3 months ago
Option B is just wishful thinking. No code? Really? That's not how C++ works, folks.
upvoted 0 times
...
Onita
3 months ago
Haha, I bet the person who wrote Option C must have been napping during the memory management lecture. Rookie mistake!
upvoted 0 times
...
Susana
3 months ago
I agree with Allene. Deleting the pointer twice like in Option C is a common mistake that can cause issues.
upvoted 0 times
Van
1 months ago
Always important to be careful with memory management in code.
upvoted 0 times
...
Almeta
2 months ago
I agree, Option D is the safest choice to prevent memory leaks.
upvoted 0 times
...
Junita
2 months ago
Yeah, I think Option C is definitely wrong. Deleting the pointer twice is a bad idea.
upvoted 0 times
...
Domitila
2 months ago
Option D is the correct one. It deletes the pointer once to avoid memory leaks.
upvoted 0 times
...
...
Allene
3 months ago
Option D is clearly the correct answer. You only need to delete the pointer once to avoid memory leaks.
upvoted 0 times
Renea
2 months ago
Yeah, you just need to delete the pointer once.
upvoted 0 times
...
Dana
3 months ago
Option D is the correct answer.
upvoted 0 times
...
...
Jospeh
3 months ago
I think the answer is D) ~Base() { delete ptr; }
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77