InterviewSolution
Saved Bookmarks
| 1. |
If an object is declared in a user defined function __________________(a) Its memory is allocated in stack(b) Its memory is allocated in heap(c) Its memory is allocated in HDD(d) Its memory is allocated in cacheI got this question during an online exam.I want to ask this question from Overloading Member Functions topic in section Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT choice is (a) Its memory is allocated in stack The explanation is: The memory for any data or object that are used in a user defined function are always allocated in the stack. This is to ensure that the object is destroyed as SOON as the function is returned. Also this ensures that the correct memory ALLOCATION and destruction is PERFORMED. |
|