C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 42)
42.
In which of the following a virtual call is resolved at the time of compilation?
From inside the destructor.
From inside the constructor.
From inside the main().
Both A and B.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 1 of 2.

Anomie said:   4 years ago
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.
(2)

Riya said:   5 years ago
Can anyone explain it properly?
(2)

VIVEK ROY said:   5 years ago
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.
(1)

Lolit said:   8 years ago
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.

Haritha reddy said:   8 years ago
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.

Priti choubey said:   9 years ago
Can you please explain the question?

Pooja Deshmukh said:   1 decade ago
What exactly means the virtual call at the time of compilation?

Archana said:   1 decade ago
Please explain this word virtual call, what's exactly mean virtual call at compilation.

Sagar said:   1 decade ago
Please any one clear this point that virtual call resolved at compilation.

Kola said:   1 decade ago
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.


Post your comments here:

Your comments will be displayed after verification.