1 static myClass* X; 2 int main() 3 ( 4 5 6 7 9 10 11...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 static myClass* X; 2 int main() 3 ( 4 5 6 7 9 10 11 12 13. 14 } Consider the following class instances in a C++ program: myClass Y = new myClass (); foo (); delete Y; return 0; void foo () { myClass Z; X= new myClass(); a) (5pt) What is the storage allocation (static/stack/heap) for the following objects? 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) (5pt) Consider one execution of the program above. The execution trace (a sequence of program state- ments 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. 1 static myClass* X; 2 int main() 3 ( 4 5 6 7 9 10 11 12 13. 14 } Consider the following class instances in a C++ program: myClass Y = new myClass (); foo (); delete Y; return 0; void foo () { myClass Z; X= new myClass(); a) (5pt) What is the storage allocation (static/stack/heap) for the following objects? 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) (5pt) Consider one execution of the program above. The execution trace (a sequence of program state- ments 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.
Expert Answer:
Answer rating: 100% (QA)
a object A Global static pointer variable and will be saved in heap storage obj... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these algorithms questions
-
Write a adjacency list and adjacency matrix representation of the following graph: 1 2 4 (3)
-
You are asked to develop a Floppy Disk program that allows users to access a floppy disk locally mounted on a computer. You are expected to use C programming language. In your program, all file I/O...
-
If the focal length of a lens is 3 centimeters and the image distance is 5 centimeters from the lens, what is the distance from the object to the lens?
-
In Exercises 3336, use possible symmetry to determine whether each graph is the graph of an even function, an odd function, or a function that is neither even nor odd. ------ -2, y CI (0,4) 2 14...
-
Ethane is burned with 150% theoretical air in a gas turbine combustor. The products exiting consist of a mixture of CO2, H2O, O2, N2, and NO in chemical equilibrium at 2800 F, 150 lbf/in 2. Determine...
-
A new pop-up restaurant serving high-end street tacos just opened and is expected to have high demand based on the chef's prior restaurant experience. The pop-up restaurant has only one window where...
-
What is the role of HR professionals in information security and privacy management?
-
The two largest diner chains in Kansas compete for weekday breakfast customers. The two chains, Golden Inn and Village Diner, each offer weekday breakfast customers a breakfast club membership that...
-
. MTS Corporation earned revenues of $339000, incurred expenses of $206000, and paid dividends of $42000. When Income Summary is closed to Retained Earnings, the amount of the debit or credit to...
-
The following salaried employees of Mountain Stone Brewery in Fort Collins, Colorado, are paid semimonthly. Some employees have union dues or garnishments deducted from their pay. Required: Calculate...
-
Suppose an operating system executes 100 processes in a second, and the time required for a context switch is negligible. Note that one millisecond is 1/1000 seconds. a. (4%) If each of those...
-
Inventory levels for Remi are currently held at $400,000 and have been increasing at a rate of 6% over the past 10 years. In order to hold down inventory costs, Remi has decided that if they exceed...
-
Explain why bond issuers might voluntarily choose to put restrictive covenants into a new bond issue.
-
Explain what the size effect is.
-
A societal utility function for an entire nation is found to be In U = 3.2 0.52lnG + 0.47 InB, where G and B are guns and butter. Interpret the coefficients. What happens to utility for the nation...
-
If you can use past returns to construct a trading strategy that makes money (has a positive alpha), it is evidence that market portfolio is not efficient. Explain why.
-
Q : Predict the products of electrolysis in each of the following: (i) An aqueous solution of AgNO; with silver electrodes. (ii) An aqueous solution of AgNQ with platinum electrodes. (iii) A dilute...
-
For the following arrangements, discuss whether they are 'in substance' lease transactions, and thus fall under the ambit of IAS 17.
-
Suppose we want to add an extra operation, remove(x), which removes x from its current set and places it in its own. Show how to modify the union/find algorithm so that the running time of a sequence...
-
Show that every AVL tree can be colored as a red-black tree. Are all red-black trees AVL?
-
a. Show that if all nodes in a splay tree are accessed in sequential order, the resulting tree consists of a chain of left children. b. Show that if all nodes in a splay tree are accessed in...
-
An entitys functional currency is: A. The currency of its parents country. B. The currency of its own country. C. The currency in which the financial statements are presented. D. The currency of the...
-
The variety of possible methods of foreign currency translation, and the different ways of treating gains arising, show that adequate harmonization for international comparison purposes is a long way...
-
Entity X based in one country (currency $) bought goods from Entity Y in another country (currency :) for :300,000 on 1 May 20X1. The spot rate on that date was $1 = :1. As at 31 December 20X1, the...
Study smarter with the SolutionInn App