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 17 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 17
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
6 months ago
I agree with you, Weldon. Deleting the pointer once in the destructor should prevent memory leaks.
upvoted 0 times
...
Weldon
6 months ago
I think the correct answer is D.
upvoted 0 times
...
Jerlene
6 months ago
B? No additional code needed? Seriously, this is a textbook example of a destructive function. You gotta delete that pointer, my friend.
upvoted 0 times
...
Alecia
6 months ago
Option C is just silly, deleting the pointer twice? That's a surefire way to cause a crash!
upvoted 0 times
...
Harley
6 months ago
Clearly, option D is the correct answer. Deleting the pointer once is the way to go to avoid memory leaks.
upvoted 0 times
Loren
5 months ago
Yes, deleting the pointer once in the destructor is the right way to prevent memory leaks.
upvoted 0 times
...
Loren
5 months ago
I agree, option D is the correct answer.
upvoted 0 times
...
Loreta
6 months ago
Yes, deleting the pointer once in the destructor is the best practice to avoid memory leaks.
upvoted 0 times
...
Loreta
6 months ago
I agree, option D is the correct answer.
upvoted 0 times
...
Loreen
6 months ago
Yes, deleting the pointer once in the destructor is the right way to prevent memory leaks.
upvoted 0 times
...
Loreen
6 months ago
I agree, option D is the correct answer.
upvoted 0 times
...
...

Save Cancel