Skip to content

Commit 4382ce3

Browse files
committed
change to pointer in main
1 parent a65b214 commit 4382ce3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Week11Assignment.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,28 @@ class Rectangle : public Shape {
6666
class Segment {
6767

6868
protected:
69-
Shape * fromShape;
70-
Shape * toShape;
69+
const Shape * fromShape;
70+
const Shape * toShape;
7171

72+
public:
73+
Segment() : fromShape(nullptr), toShape( nullptr ) {
74+
}
7275
};
7376

7477
int main(int argc, char *argv[])
7578
{
76-
Rectangle rec1(1, 2, 3, 4);
79+
Rectangle rec1(1, 2, 3, 4);
7780

78-
cout << rec1;
81+
//cout << rec1;
7982

8083
Rectangle rec2(1, 2, 6, 8);
8184

8285
Segment s1;
8386

84-
s1 += rec1;
85-
s1 += rec2;
87+
s1 += &rec1;
88+
s1 += &rec2;
8689

87-
s1 -= rec1;
90+
s1 -= &rec1;
8891

8992
return 0;
9093

Week11Assignment.exe

74.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)