Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Points with a struct

English

Points with a struct

A struct groups related values into one type. Here struct Point holds an x and a y. Complete two functions: make_point builds and returns a Point, and move_point shifts an existing one. With a pointer to a struct you reach its fields with ->, so p->x += dx moves it.

ไทย

Pointers กับ struct

struct รวมค่าที่เกี่ยวข้องเข้าเป็นประเภทหนึ่ง ที่นี่ struct Point เก็บ x และ y ให้ทำฟังก์ชันสองตัว: make_point สร้างและส่งกลับ Point, และ move_point ย้ายตำแหน่งที่มีอยู่แล้ว ด้วย pointer ไปยัง struct คุณสามารถเข้าถึง field ได้ด้วย -> ดังนั้น p->x += dx จึงย้ายตำแหน่งได้

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP