Answer to Question #213954 in C++ for Muhammad danyal

Question #213954

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?          

c)    Why we cannot able to create objects of abstract classes give reasonable justification of that.                   



1
Expert's answer
2021-07-05T18:14:38-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;
}

c) A object of abstract class  cannot be created because there is an abstract method which has nothing.




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