Consider the following C++ code: static long z = 5 ; int d = 10 ; int *ptr1 = new int[2] ; void myfun ( int param1 ){ static int x = 100 ; float y = 50; int *ptr2 = new int ; // . . .; delete ptr2 ;...


Consider the following C++ code:



static long z = 5 ;


int d = 10 ;


int *ptr1 = new int[2] ;



void myfun ( int param1 ){


     static int x = 100 ;


     float y = 50;


     int *ptr2 = new int ;


     // . . .;


    delete ptr2 ;


    delete ptr1 ;


}


void fun2() {


    static int num =5;


    int var  = 10;


}





Identify the storage bindings types, storage locations and lifetime of each variable.

Select one for storage binding types: static, stack dynamic, explicit heap dynamic, implicit dynamic

Select one for storage locations: static segment, stack, heap.

Select one for lifetimes: Entire program, Execution of funct1, From Line ... to Line ...




(a) Storage binding types<br>Z:<br>d:<br>ptrl:<br>*ptrl:<br>paraml:<br>X:<br>y:<br>ptr2:<br>*ptr2:<br>num:<br>var:<br>

Extracted text: (a) Storage binding types Z: d: ptrl: *ptrl: paraml: X: y: ptr2: *ptr2: num: var:
(b) storage locations:<br>Z:<br>d:<br>ptrl:<br>*ptrl:<br>paraml:<br>X:<br>y:<br>ptr2:<br>*ptr2:<br>num:<br>var:<br>(c) Life Time<br>Z:<br>d:<br>ptrl:<br>*ptrl:<br>paraml:<br>y:<br>ptr2:<br>*ptr2:<br>num<br>var:<br>

Extracted text: (b) storage locations: Z: d: ptrl: *ptrl: paraml: X: y: ptr2: *ptr2: num: var: (c) Life Time Z: d: ptrl: *ptrl: paraml: y: ptr2: *ptr2: num var:

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here