-->
当前位置:首页 > 题库

PROGRAMMING:Application of inheritance class

Luz5年前 (2021-05-10)题库425
Create a class named Square: define the private member field edge in the class, and define the set and get methods of the field; Complete the construction method of this class; This class contains methods such as perimeter and area; Define subclass cube class: complete the construction method of this class; Implement the area and volume methods of this class. Create a square object in main, calculate and display its perimeter and area; Create a cube object, calculate and display its area and volume. The main program calls the main function.
###Input example:
```in
six
seven
```
###Output example:
```out
Square with side length 6, area = 36
Square with side length 6, perimeter = 24
Cube with 7 sides, area = 294
Cube with 7 sides, volume = 343
```







answer:If there is no answer, please comment