Level 2

Abstract Classes

views

4:59
However we want to know the area of the rectangle. Even though the function getArea() is available in the class Shape, it is not of any use to us as it doesn’t know what type of shape it is and hence cannot calculate the area. This information is available only with the derived class. Sometimes while programming, if we accidentally forget to write any function, it leads to this problem of getting some incorrect answers. In order to ensure that this problem does not arise, pure virtual functions are used.