C++20 sections · 1024 units
Open in Course

Creating Struct Variables

Making actual objects

Once you define a struct, create variables of that type like primitives. Write the struct name, then the variable name. That variable now has all the members you defined. Example: Point p; creates a variable p of type Point.

It has members x and y inside. You don't get just one, you get both together as a unit. Create multiple variables from the same struct. Point a, b, c; gives three separate Point variables, each with their own x and y.

Changing a.x doesn't touch b.x.