forked from wadehuber/codeexamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.cpp
More file actions
56 lines (47 loc) · 1.51 KB
/
Copy pathheaders.cpp
File metadata and controls
56 lines (47 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<iostream>
#include"shape.hpp"
#include"rectangle.hpp"
#include"circle.hpp"
#include"triangle.hpp"
#include"square.hpp"
using namespace std;
int main() {
Rectangle r(7, 5);
Triangle t(3, 5);
Circle c(4);
Square q(8);
Shape * sArray[] = {
new Rectangle(4, 9),
new Circle(5),
new Triangle(13,8),
new Rectangle(10, 4),
new Circle(7),
new Triangle(3,6),
new Square(1),
new Square(3)
};
cout << "Rectangle variable r:" << endl;
r.print();
r.printType();
cout << "area=" << r.area() << " perimeter=" << r.perimeter() << endl;
cout << endl << "Triangle variable t:" << endl;
t.print();
t.printType();
cout << "area=" << t.area() << " perimeter=" << t.perimeter() << endl;
cout << endl << "Circle variable c:" << endl;
c.print();
c.printType();
cout << "area=" << c.area() << " circumference=" << c.perimeter() << endl;
cout << endl << "Square variable q:" << endl;
q.print();
q.printType();
cout << "area=" << c.area() << " perimeter=" << c.perimeter() << endl;
cout << endl << "Shape* array sArray:" << endl;
for (const Shape * s : sArray) {
s->printType();
cout << " ";
s->print();
cout << " area=" << s->area() << " perimeter=" << s->perimeter() << endl;
}
return 0;
}