Answer Posted / uma sankar pradhan
A virtual destructor is needed when we are deleting a
object of derived class using a base class pointer.
i.e.,
base *b=new derived;
delete(b);
Let's say,we have allocated memory dynamically in derived
class constructor to a pointer data member and we
deallocated it in the destructor to avoid memory leakage
When the object is deleted through base class pointer,
only the base class destructor is invoked.consequently,the
dynamically allocated space remains unreleased.so it leads
to memory leak
Is This Answer Correct ? | 34 Yes | 1 No |
Post New Answer View All Answers
What is a function in oop?
What is oops in simple words?
What is stream in oop?
What is the renewal class?
What is difference between abstraction and encapsulation?
What is difference between inheritance and polymorphism?
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.
Why do we use polymorphism?
What is overloading in oops?
Why interface is used?
What is polymorphism what are the different types of polymorphism?
Can we have inheritance without polymorphism?
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.
What is constructor in oop?
What is encapsulation with example?