Structs C++ - Reading Assignments

  1. We need structs to manage multiple variables at once.
  2. Members in a struct are variables that are inside the struct.
  3. You access member variables using a . operator.
  4. A nested struct is a struct inside of a struct.
2 Likes

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.

2 Likes
  1. Why do we need structs?
    To bundle multiple variables together into a single type

  2. What are members in a struct?
    A variable, function, or type that belongs to a struct

  3. How do you access a member inside a struct?
    Using a member selection operator

  4. What is a nested struct?
    When you have a struct inside a struct

  1. 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.

  1. 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.

  1. 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.

  1. What is a nested struct?

The structure declared within another structure.