コンテンツへスキップ

Structs and typedef: . vs ->

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 Point p holds x = 2 and y = 5; p.x and ptr->x both give 2

プリント

ログインまたはアカウント作成

IGCSE, A-Level & AP