C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.42)

42. 

In which of the following a virtual call is resolved at the time of compilation?

[A]. From inside the destructor.
[B]. From inside the constructor.
[C]. From inside the main().
[D]. Both A and B.

Answer: Option D

Explanation:

No answer description available for this question.

Shilpa said: (Jun 26, 2012)  
Please explain why?

Ravindra Bagale said: (Jul 2, 2012)  
@Shilpa.

To construct an object, a constructor needs the exact type of the object it is to create. That means compiler has to know the type of object before the creation, that is only possible at compile time.

Mohit said: (Feb 13, 2013)  
To construct an object, a constructor needs the exact type of the object it is to create. That means compiler has to know the type of object before the creation, that is only possible at compile time.

Similarly we cannot create classes having same name i. e, each class name is unique. Constructor and destructor name is similar to classname.

Anil said: (Jun 25, 2014)  
To construct an object, a constructor needs the exact type of the object it is to create. That means compiler has to know the type of object before the creation, that is only possible at compile time.

Similarly we cannot create classes having same name i.e., each class name is unique. Constructor and destructor name is similar to classname.

Kola said: (Jul 3, 2014)  
To construct an object, a constructor needs the exact type of the object it is to create. That means compiler has to know the type of object before the creation, that is only possible at compile time.

Similarly we cannot create classes having same name i.e., each class name is unique. Constructor and destructor name is similar to classname.

Sagar said: (Aug 22, 2014)  
Please any one clear this point that virtual call resolved at compilation.

Archana said: (Oct 25, 2014)  
Please explain this word virtual call, what's exactly mean virtual call at compilation.

Pooja Deshmukh said: (Dec 8, 2014)  
What exactly means the virtual call at the time of compilation?

Priti Choubey said: (Dec 5, 2016)  
Can you please explain the question?

Haritha Reddy said: (Jun 9, 2017)  
Virtual call at the compilation time means if we want to call the same named function with in the class it possible by only defining the base class as virtual. So we are calling this virtual function at compile time.

Lolit said: (Dec 3, 2017)  
To construct an object, a constructor needs the exact type of the object it is to create. That means compiler has to know the type of object before the creation, that is only possible at compile time.

Similarly we cannot create classes having same name i.e., each class name is unique. Constructor and destructor name is similar to classname.

Vivek Roy said: (Mar 21, 2020)  
Yes, I can understand to construct an object, the constructor must be of same type as the class. But it is not implemented constructor.

Second, at the the time of calling constructor, virtual table would not have look up to, so how can we make virtual call inside a constructor?

But it is possible inside a destructor.

Please let me know where I am wrong.

Riya said: (May 3, 2020)  
Can anyone explain it properly?

Anomie said: (Aug 23, 2021)  
To construct an object, a constructor needs the exact type of object it is to create. That means the compiler has to know the type of object before the creation, which is only possible at compile time.

Similarly, we cannot create classes having the same name i.e., each class name is unique. The constructor and destructor name is similar to the class name.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.