Question: 4. (5 points) Consider the following skeletal C++ program: void fun1(void) { int *pf = new int[10]; //pf is a reference to a dynamically allocated

 4. (5 points) Consider the following skeletal C++ program: void fun1(void)

4. (5 points) Consider the following skeletal C++ program: void fun1(void) { int *pf = new int[10]; //pf is a reference to a dynamically allocated integer array } void fun2(void) { int b; } void main() { int a; //pm is a reference to a dynamically allocated double array double *pm = new double [5]; fun1(); delete []pm; fun2(); //delete the array referenced by pm } (a) what is the lifetime of variable a, b, pm and pf respectively? (b) what is the lifetime of the double array allocated in main(), and integer array allocated in fun1() respectively

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!