|
|
 |
|
|
|
|
74:
75: Square::Square(int len, int width):
76: Rectangle(len,width)
77:
78: {
79: if (GetLength() != GetWidth())
80: cout << Error, not a square a Rectangle??\n;
81: }
82:
83: int main()
84: {
85: int choice;
86: bool fQuit = false;
87: Shape * sp;
88:
89: while (1)
90: {
91: cout << (1)Circle (2)Rectangle (3)Square (0)Quit: ;
92: cin >> choice;
93:
94: switch (choice)
95: {
96: case 1: sp = new Circle(5);
97: break;
98: case 2: sp = new Rectangle(4,6);
99: break;
100: case 3: sp = new Square(5);
101: break;
102: default: fQuit = true;
103: break;
104: }
105: if (fQuit)
106: break;
107:
108: sp->Draw();
109: cout << \n;
110: }
111: return 0;
112: } |
|
|
|
|
|
|
|
|
(1)Circle (2)Rectangle (3)Square (0)Quit: 2
× × × × × ×
× × × × × ×
× × × × × ×
× × × × × ×
(1)Circle (2)Rectangle (3)Square (0)Quit:3
× × × × × |
|
|
|
|
|