Question: Function foo and two pointers p,sp are given below. 63 template 64 void foo(shared_ptr ptr) 65 { 66 *ptr = 67 } 68 auto

Function foo and two pointers p,sp are given below. 63 template 64 void foo(shared_ptr ptr) 65 { 66 *ptr = 67

Function foo and two pointers p,sp are given below. 63 template 64 void foo(shared_ptr ptr) 65 { 66 *ptr = 67 } 68 auto p = new int(); 69 auto sp = (b) foo(p); TO); Are the following function calls legal? Any memory leak for each function call? Briefly explain your answers. (a) foo(sp); make_shared (); Enter your answer here (c) foo(shared_ptr(p)); Enter your answer here Enter your answer here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The image shows a snippet of C code defining a template function foo that takes a stdsharedptr and two variables defined using auto which are pointers ... View full answer

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 Programming Questions!