1. A failure to write an assignment operator for a class that holds dynamic memory results in what problematic condition? A. A seg fault B. The computer runs out of memory. C. Two objects sharing the same array. D. Two objects not being able to look alike
2. When the condition described in an assert if false a. the program shuts down b. the user is given a warning that tells them they did something wrong. c. the errors in the code are fixed d. the program continues to run
Expert Answer
1. C: The two objects holding the same array… as the class contains the reference to the array always and when the assignment is copied from one object to the other, both objects contain the reference to the same memory location.. hence if one object changes the value at that location, the second objects sees the updated value, which is not right…
2. a) The program shuts down.. The asserts are used to check for the condition which are not controllable by the programmer, such as insufficient memory, or stack overflow exceptions etc.. If the exception is something that can be resolved by the programmer using the code, he/she should do that… Assert indicates a condition which is environment based mainly and thus we can’t resolve it by code.