a) Can we declare base class constructor or destructor as virtual if yes then why we want to do?
b) How we can declare a class as abstract and why we need abstract classes?
Why we cannot able to create objects of abstract classes give reasonable justification of that.
a) A base class constructor cannot be declared as virtual.
A base class destructor can be declared as virtual. Virtual makes sure the destructor starts at the top instead of the middle
b)
Abstract class helps in information hiding
class Shape {
public:
// creating a pure virtual function
virtual void calculateArea() = 0;
}
Comments
Leave a comment