7 喜歡 0 不喜歡
243 瀏覽

Exercise 1

Using the file point.cpp (Click to download), add a member function print to the class Point so that it prints out coordinates as:

	(2, 3)

for a point with coordinates (2, 3). Test it in main().

Exercise 2

Write a definition of a class Rectangle using the Point class. A rectangle is specified by two corner points (bottom left and top right). The sides of the rectangle are parallel to the coordinate axes. The implementation of the class should be as follows: 

  • The private data members of the class include all 4 corner points of the rectangle.
  • There are two constructors: one takes two points as arguments and creates a rectangle with the first point as the bottom left corner and the second as the top right corner, the other (default) constructor creates a rectangle with the corners (0,0), (1,0), (0,1), (1,1). 
    Hint: use functions Set_X, Set_Y from the class Point to set the values of the corner points.
  • The print member function prints all 4 corners of the rectangle, using the member function print of the class Point.

Test the class Rectangle in main(), demonstrate that all member functions work as specified.

[正常] 開放式問答 - 最新提問 分類:Introduction to Computer Programming I (C) | 用戶: (12.1k 分)
ID: 26000 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 243 瀏覽
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.178.123
©2016-2024

相關問題

0 喜歡 0 不喜歡
0 回答
[正常] Coding (C++) - 最新提問 5月 17, 2018 分類:Introduction to Computer Programming II (C++) |
ID: 52070 - 從幾時開始: 2018-04-26 17:48 - 到幾時結束: 無限制
| 128 瀏覽
6 喜歡 0 不喜歡
0 回答
[正常] Coding (C) - 最新提問 10月 10, 2017 分類:Introduction to Computer Programming I (C) | 用戶: thopd (12.1k 分)
ID: 25999 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 109 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶