HW09 Abstract Classes & Virtual Functions
- Create an abstract class called Shape with pure virtual members called calcPerimeter and calcArea. Create subclasses of Shape called Rectangle and Triangle that inherited the pure virtual members above.
- Write two non-member functions called printPerimeter and printArea that call the methods calcPerimeter and calcArea respectfully.
- Instantiate a Rectangle and a Triangle object.
- Input the length and width of a rectangle and then call the functions printPerimeter and printArea.
- Input the length of the three sides of a triangle and then call the functions printPerimeter and printArea.
- Output the perimeter and area of the rectangle and triangle objects.
Use the command script to capture your interaction compiling and running the program, including all operations, as shown below:
CS1C Fall 2018 TTH HW09 50pts Due: Th 10/11/2018
[email protected] ~/cs1c/hw/09 $ script hw09.scr Script started, file is hw09.scr [email protected] ~/cs1c/hw/09 $ date
[email protected] ~/cs1c/hw/09 $ ls -l
[email protected] ~/cs1c/hw/09 $ make all
[email protected] ~/cs1c/hw/09 $ ls -l
HW09 Abstract Classes & Virtual Functions [50 pts]
[email protected] ~/cs1c/hw/09 $ ./hw09
// print out output from steps 4 thru 6
[email protected] ~/cs1c/hw/09 $ exit Script done, file is hw09.scr
[email protected] ~/cs1c/hw/09 $ make tar
Reviews
There are no reviews yet.