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

What language is oop?

603


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

709


What is the difference between procedural programming and oops?

570


2. Give the different notations for the class.\

1596


Why do while loop is used?

586






hi all..i want to know oops concepts clearly can any1 explain??

1685


Can we create object of interface?

615


Prepare me a program for the animation of train

2012


What is use of overloading?

618


What is abstraction encapsulation?

667


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2774


What are two types of polymorphism?

622


What is polymorphism oop?

635


What is constructor overloading in oop?

618


What is destructor give example?

612