In c++ there is only virtual destructors, no constructors. Why?

Answer Posted / uma sankar pradhan

constructors are invoked at the time of object creation.
The v-table for virtual function mechanism is not
intialised properly during the constructor invocation.
So constructors cannot be virtual

But,destructors can be virtual.Because the V-table is
properly initialised at the time of object creation.
So the v-table is available for the destructors.
Destructors can be made pure virtual also.But unlike other
member functions,it must be redfined outside the class.

Is This Answer Correct ?    57 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2038


Can bst contain duplicates?

670


What is abstraction in oops with example?

776


What is overloading in oops?

598


What is data binding in oops?

588






Explain the concepts involved in Object Oriented programming.

642


What does and I oop and sksksk mean?

654


can we make game by using c

3431


How to call a non virtual function in the derived class by using base class pointer

5278


class type to basic type conversion

1839


what type of questions

1697


How do you define social class?

603


What is abstraction in oop with example?

646


When not to use object oriented programming?

572


What are the three parts of a simple empty class?

1462