What is virtual constructor paradigm?
Answers were Sorted based on User's Feedback
Answer / malini
There is no concept like Virtual Constructor and where as
Constructor cant be virtual. Constructor is a code which is
responsible for creating a instance of a class and it cant
assigned to any other object by using appending
keyword 'virtual'
Is This Answer Correct ? | 8 Yes | 0 No |
Answer / priyanka kokil
I want to modify the above answer. A constructor cannot be
virtual because at the time when the constructor is invoked
the virtual table would not be available in the memory.
Hence we cannot have a virtual constructor. But we can have
virtual destructor which is defined in Answer #2
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / subhashish sen
Hi Priyanka Kokil,
What ever u have answered its not 100% correct..As we know
for every virtual function in a class one VTABLE is created
internally and constuctor is an entity who intializes this
VTABLE for all virtual functions of a class.For example if
we have a base class and a derived class derived from
it,then 2 VTABLE will be created one for base and one for
derived class.So if you make constructor as virtual then
who will create VTABLE for this constructor.Thats why
constructor can never be virtual.
Thanks!!!!!If u have ny suggession plz reply..
Is This Answer Correct ? | 5 Yes | 3 No |
Answer / priyanka kokil
A virtual destructor is one that is declared as virtual in
the base class and is used to ensure that destructors are
called in the proper order. It is to be remembered that
destructors are called in the reverse order of inheritance.
If a base class pointer points to a derived class object
and we some time later use the delete operator to delete
the object, then the derived class destructor is not called.
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / priyanka kokil
Hi Subhashish Sen,
Thanks for your response and adding more details to my
answer.
Thanks
Is This Answer Correct ? | 0 Yes | 3 No |
What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)
What is the Maximum Size that an Array can hold?
55 Answers Adobe, FutureSoft, HCL, Infosys, Satyam, TCS, Wipro,
What is namespace std; and what is consists of?
Can you Mention some Application of C/C++?
What are the conditions that have to be met for a condition to be an invariant of the class?
What is the use of :: operator in c++?
When is dynamic checking necessary?
Explain differences between alloc() and free()?
Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300
What are the two types of polymorphism?
#include<iostream.h> void main() { class x { public: int func(int) { cout<<"cool"; return 1; } } }
Why c++ is not a pure oop language?