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
What is byval and byref? What are differences between them?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What is the important feature of inheritance?
Why do while loop is used?
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
Write a program to reverse a string using recursive function?
What is the renewal class?
What is debug class?what is trace class? What differences are between them? With examples.
What is multilevel inheritance in oop?
What is constructor in oop?
What is abstract class in oops?
Why do we use encapsulation in oops?
Why is oop better than procedural?
What is abstraction and encapsulation?
What are the types of abstraction?