Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bắt đầu tùy chọn gỡ lỗi (cũng có sẵn từ một nút trên thanh công cụ Debug) chỉ đơn giản là thực hiện một chương trình lên đến điểm dừng đầu tiên (nếu có) nơi thực hiện sẽ ngăn chặn. Sau khi bạn đã kiểm tra tất cả các bạn cần một điểm dừng, | Chapter 7 Coordinates of Hut2 are Hut2.Left Hut2.Top and Hut2.Right Hut2.Bottom iimpo PDF Merg eandSplit Unregistered Version - http www.simpopdf.com The area of the yard is Area Yard cout endl The area of the pool is Area Pool endl return 0 Function to calculate the area of a rectangle long Area RECTANGLE aRect return aRect.Right - aRect.Left aRect.Bottom - aRect.Top Function to Move a Rectangle void MoveRect RECTANGLE aRect int x int y int length aRect.Right - aRect.Left Get length of rectangle int width aRect.Bottom - aRect.Top Get width of rectangle aRect.Left x Set top left point aRect.Top y to new position aRect.Right x length Get bottom right point as aRect.Bottom y width increment from new position return The output from this example is Coordinates of Hut2 are 10 90 and 35 110 The area of the yard is 12000 The area of the pool is 1600 How It Works Note that the struct definition appears at global scope in this example. You ll be able to see it in the Class View tab for the project. Putting the definition of the struct at global scope allows you to declare a variable of type RECTANGLE anywhere in the .cpp file. In a program with a more significant amount of code such definitions would normally be stored in a .h file and then added to each .cpp file where necessary by using a include directive. You have defined two functions to process RECTANGLE objects. The function Area calculates the area of the RECTANGLE object that you pass as a reference argument as the product of the length and the width where the length is the difference between the horizontal positions of the defining points and the 328 Defining Your Own Data Types width is the difference between the vertical positions of the defining points. By passing a reference the code runs a little faster because the argument is not copied. The MoveRect function modifies the defining points of a RECTANGLE object to position it at the coordinates x y which are passed as argu-ỉimpo PDF MergeeancT .