0

Finding Area,Perimeter, of a rectangle through inheritance

inheritance

15th Apr 2019, 9:34 AM
ian mong'are
2 Answers
+ 1
At first think about rectangles. It has 4 sides but it should be clear that you don't need all sides. Only two: length and width. Then search for the formulars to calculate area and perimeter. Classes: https://www.sololearn.com/learn/CPlusPlus/1710/?ref=app A class has attributes (data) and methods. length and width are your attributes. calcArea and calcPerimeter are your methods. Which types? I think double is good. double length double width calcArea -> return a double value for the area calcPerimeter -> return a double value for perimeter I am not sure why you should need inheritance. Here is a link to the lesson: https://www.sololearn.com/learn/CPlusPlus/1907/?ref=app
15th Apr 2019, 2:20 PM
Denise Roßberg
Denise Roßberg - avatar