Question: 1 2 3 Problem 1 [5pt] Consider the following class instances in a C++ program: static myclass* X; int main() { myClass* Y = new
![1 2 3 Problem 1 [5pt] Consider the following class instances](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/670400e8c48a4_624670400e8462ef.jpg)
1 2 3 Problem 1 [5pt] Consider the following class instances in a C++ program: static myclass* X; int main() { myClass* Y = new myClass(); foo(); delete Y; return 0; } 4 5 6 7 8 9 10 11 12 void foo () { myClass Z; X = new myClass(); } 13 14 a) (2.5pt) What is the storage allocation (static/stack/heap) for the following objects? C . . object A: the pointer X object B: the pointer Y object C: the myClass object created at line 4 object D: the myClass object created at line 12 object E: the myClass object created at line 13 . b) (2.5pt) Consider one execution of the program above. The execution trace (a sequence of program statements executed at run time) of this program is 4 5 12 13 6 7 For each object above (i.e., object A to E), write down its lifetime (use a subset of execution trace, e.g., 12 13 to represent the lifetime). Assume the lifetime of a heap-allocated object starts from new and ends after delete and include both new and delete
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
