...

/

Challenge 2: Implement and Override a Method

Challenge 2: Implement and Override a Method

Can you override the CalcArea() method in a derived class? A solution is placed in the solution section to help you, but we suggest you try to solve it on your own first.

Polymorphism in Shapes

Shapes are a perfect example of polymorphism. There are many types of shapes, e.g., circles, triangles, squares, rectangles, etc. Each of these shapes has an area but the way it is calculated is different for each shape. For example, a square’s area will be calculated as follows: ...