- We need structs to manage multiple variables at once.
- Members in a struct are variables that are inside the struct.
- You access member variables using a . operator.
- A nested struct is a struct inside of a struct.
1) Why do we need structs?
When we have a variable with more than 1 atribute we can create a struct to bundle up multiple variables into a single type.
2) What are members in a struct?
The members of a struct are the fileds (variables) that we attribute to them, that are part of the struct.
3) How do you access a member inside a struct?
structName.memberName
4) What is a nested struct?
Is a struct defined inside of a struct.
-
Why do we need structs?
To bundle multiple variables together into a single type -
What are members in a struct?
A variable, function, or type that belongs to a struct -
How do you access a member inside a struct?
Using a member selection operator -
What is a nested struct?
When you have a struct inside a struct
- Why do we need structs?
A struct (short for structure) is a program-defined data type that allows us to bundle multiple variables together into a single type.
- What are members in a struct?
The variables that are part of the struct. A member is a variable, function, or type that belongs to a struct (or class). All members must be declared within the struct (or class) definition.
- How do you access a member inside a struct?
access a specific member variable, we use the member selection operator (operator.) in between the struct variable name and the member name.
- What is a nested struct?
The structure declared within another structure.