Answer to Question #213894 in C++ for Anas

Question #213894

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.


1
Expert's answer
2021-07-05T14:14:12-0400

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;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS