Question: I've attached the c++ code, I need help with the questions on the other attachment a) Using raw (ordinary) pointers has a number of serious

 I've attached the c++ code, I need help with the questionson the other attachment a) Using raw (ordinary) pointers has a number

I've attached the c++ code, I need help with the questions on the other attachment

a) Using raw (ordinary) pointers has a number of serious drawbacks. Name three issues which can occur when using raw pointers and for each issue provide a short code sample illustrating the problem. (9 marks) b) Examine the code in the figure and answer the following questions: i) This program compiles and runs but has undefined behaviour in certain circumstances. Determine what these circumstances are and explain why the behaviour is undefined. (5 marks) ii) Identify the particular line numbers in the main function at which the behaviour may be undefined. (2 marks) iii) Rewrite the LuckyPacket class using a unique_ptr to Toy and provide additional functions which will ensure correct and consistent behaviour when it is used in main. ( 8 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!