C++20 sections · 1024 units
Open in Course

Accessing Nested Members

Chaining member access

When structs nest, chain dot operators to reach inner members. Each dot goes one level deeper. Read left to right: each step takes you further into the structure. Example: rect.topLeft.x = 10; means "from rect, go to topLeft, from there go to x, then assign 10." You drill through layers.

Three levels means three dots. Think of folders on a computer. rect is the folder, topLeft is a subfolder, x is a file. Use with dots instead of slashes.