Subscribe to the Largest Online Community of Students of virtual university of Pakistan

vuZs is a forum where students of Virtual University of Pakistan enlighten themselves. A place for the student to interact, exchange ideas in order to discuss issues, studying strategies, quality of education and above all Old papers ,Quizzes, assignments and related stuff is also provided on vuZs page. :::| Official Website: www.vuzs.info >

Translate

Tuesday, July 27, 2010

CS201 When an object of a class is defined inside another class then

When an object of a class is defined inside another class then,

                                     Destructor of enclosing class will be called first

                                     Destructor of inner object will be called first

                                     Constructor and Destructor will be called simultaneously

                                     None of the given option

I am agree with Rana AQ, here is bit description in support of it

Ref
Lesson 40

complete process will be like this in this case

first constructor of inner object will be called then constructor of enclosing class.
Because until inner object is not initialized enclosing class can not understand the memory allocation and structure of inner object.

In case of destructor it will be in reverse order(first Destructor of encolsing class will be called and then destruct or of object will be called).