What is virtual constructor paradigm?




Answers were Sorted based on User's Feedback



What is virtual constructor paradigm?..

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

What is virtual constructor paradigm?..

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

What is virtual constructor paradigm?..

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




What is virtual constructor paradigm?..

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

What is virtual constructor paradigm?..

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

Post New Answer



More C++ General Interview Questions

Implement strcmp

3 Answers   Citadel, Bloomberg,


structure contains int, char, float how it behaves for big endian and little endian?

1 Answers   BITS,


show that among any group of five (not necessary consecutive ) integers, there are two with the same remainder when divided by 4.

1 Answers  


i have given a project to create examination seating plan system in c++. so can anyone send me the answer of this question quickly??????

1 Answers  


write a program that will produce the ff. output. "what fruit will you buy? 1)apple 2)orange 3)mango ENTER CHOICE (1,2 or 3)> HOW MANY WILL YOU BUY?> THAT WILL COST XX.XX

1 Answers  






Have you used MSVC? What do you think of it?

2 Answers   Google,


1.Between 100 and 999 are some numbers that have the characteristics that if you cube the individual digits and sum together you will get the same number. 2. A program that can accept as input an integer and output the equivalent of that number in words.

3 Answers  


what is the size of a class which contains no member variables but has two objects??? is it 1 or 2??

4 Answers  


Write a corrected statement in c++ so that the statement will work properly. x + y=z;

2 Answers  


What is Memory Alignment?

2 Answers   TCS,


what is the behaviour of C and C++ compiler for the below statements. int *p; p = malloc(100); Is the behaviour same ? or different ?

2 Answers  


If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2.

1 Answers  






Categories