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

Grouping related data

  • A struct groups several values into one thing. A point has an x and a y; a rectangle has a width and a height.
  • Each value inside is called a member (or field). They can have different types.
  • Structs let you pass one tidy thing around instead of many loose variables.

ไทย

การจัดกลุ่มข้อมูลที่สัมพันธ์กัน

  • Struct กลุ่มหลายค่าให้เป็นสิ่งเดียว จุดหนึ่งมี x และ y; รูปสี่เหลี่ยมผืนผ้ามี width และ height
  • แต่ละค่าภายในเรียกว่า Member (หรือ Field) สามารถมีประเภทต่างกัน
  • Struct ช่วยให้คุณส่งสิ่งที่เป็นระเบียบชิ้นเดียวไปมาแทนตัวแปรอิสระจำนวนมาก

A Point struct with x and y; reach a field with . on the struct, or -> through a pointer

Handout · ⁨เอกสารประกอบการเรียน⁩

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

IGCSE, A-Level & AP