Structs C++ - Reading Assignments

1. Why do we need structs?
When we need more than one variable in order to represent an object.

2. What are members in a struct?
The variables that are part of the struct are called members.

3. How do you access a member inside a struct?
By the use of a member selection operator which is period. For example; paul.age{32}.

4. What is a nested struct?
A nested struct is a struct that contains other structs.

1 Like
  1. Why do we need structs?
    To be able to store variables together easier
  2. What are members in a struct?
    variables that are part of struct
  3. How do you access a member inside a struct?
    members are accesed by using a selection operator β€œ.”, after the name given to the struct before
  4. What is a nested struct?
    A struct inside another struct
1 Like

Why do we need structs?
To create our own customized data types.

What are members in a struct?
Variables that are part of the struct.

How do you access a member inside a struct?
struct.member

What is a nested struct?
It is a struct that contains other struct.

1 Like
  1. We need structs to be able to store multiple data points in a single variable, similar to storing different data points in an object.
  2. Members of a struct are the different variables within the struct. For example, struct Employee can have different data points inside this struct like name, salary, years worked in company
  3. structbName.memberName
  4. A nested struct is a struct within another struct. For example again with the struct Employee, the Employee struct can be within struct Company
1 Like
  1. Why do we need structs? β€” when need more variables to represent a single object
  2. What are members in a struct? β€” variables within struct
  3. How do you access a member inside a struct? β€” structName.memberName
  4. What is a nested struct? β€” when a struct is declared within another struct (like employee struct is declared inside a company struct), when a struct member is another struct
1 Like

1. Why do we need structs? So we can group mixed data type variables into a single object.

2. What are members in a struct? fields or variables.

3. How do you access a member inside a struct? we use the member selection operator β€œ.” joe.id or joe.age.

4. What is a nested struct? A struct within a struct.

1 Like
  1. Why do we need structs? to store multiple variables for an object.
  2. What are members in a struct? the variables
  3. How do you access a member inside a struct? struct.member
  4. What is a nested struct? a struct defined within a struct
1 Like
  1. It gives us a reusable way to create certain objects with certain variables. Like a Person with a name, age and a gender.
  2. Members are the variables of the struct.
  3. struct.member, for example β€œoskari.age”
  4. Another struct inside a struct
1 Like
  1. The aggregate data type struct (short for structure) allows us to group variable of mixed data types together into a single unit and allows us to write more concise code

  2. The variables inside the struct declaration are called members

  3. Member selection operator (period). e.g Ollie.gender

  4. Structs that contain structs

1 Like
  1. We need structs to better organize our code by assigning multiple variables to one single unit.
  2. Members in a struct are the variables that take part in it.
  3. You can access any member of a struct by writing the struct name followed by a period and then the name of the member. Ex: struct.member;
    4.A nested struct is when you place struct inside another struct which you can call on and access both structs members.
1 Like
  1. Why do we need structs?
    Struct is one of the simplest aggregate data types there is. Groups multiple individual variables together. Is used when more than one variable in order to represent an object is needed.
  2. What are members in a struct?
    It is variables that are part of the struct, carrying its own variables, also called fields.
  3. How do you access a member inside a struct?
    To access an individual member of a Struct, we use the member selection operator (which is a period); ie. josh. age, josh to access the element in the Struct, the β€œ.” as selection operator and age as to return the age variable.
  4. What is a nested struct?
    It is a Struct within a Struct.
1 Like
  1. It allows you to create you own datatype when you need to aggregate data types
  2. They are the fields of the struct that hold values for the struct object
  3. create an object of the Structs type (ex: struct Employee {
    } )
    and if the Employee has a field id, you would say:
    Employee steve{};
    steve.id = 27;
  4. when an object of one struct is set as a field inside another struct
1 Like

Why do we need structs?
so that we can group different data types together into one single unit, for ease of use

What are members in a struct?
the variables that are part of the struct

How do you access a member inside a struct?
using the member selection operator ( a period), for example ivan.age

What is a nested struct?
a struct containing another struct

1 Like

Structs are needed where more than one variable is required in order to represent an object. This negates the need to repeat variables unnecessarily in functions.

Variables that are part of a struct are called members (or fields).

Members of a struct are accessed by using a member selection operator (which is a period).

A nested struct is a struct that contains other struct(s).

1 Like

1. Why do we need structs?
Structs allow us to create a user defined aggregate data type.

2. What are members in a struct?
Variables inside the struct.
3. How do you access a member inside a struct?
struct.member
Using the member selection operator (.).

4. What is a nested struct?
Nested structs are structs that contain other structs.

1 Like
  1. Why do we need structs?
    Because we can use more than one variable to represent an object.
  2. What are members in a struct?
    The variables in the struct
  3. How do you access a member inside a struct?
    By using the member selection operator which is basically a period.
    referenced_struct.variable_of_referenced_struct
  4. What is a nested struct?
    A struct within a struct .
1 Like
  1. We need structs when an object is represented by more than one variable.
  2. Each variable, of the multiple variables that represent an object, is called a member.
  3. With a member selection operator which is the period symbol
  4. A struct inside of a struct. e.g. a subcategory of a category
1 Like
  1. To structure and store valuables

  2. Members are the different variables that are in the struct

  3. struct.member

  4. A struct inside another struct

1 Like
  1. Why do we need structs?
    To group variables of different data types together into a single unit
  2. What are members in a struct?
    The variables that are part of the struct
  3. How do you access a member inside a struct?
    By using the member selection operator which is a a period
    struct.member
  4. What is a nested struct?
    A struct within another struct
1 Like
  1. We need structs to group variables of mixed data types together into a single unit.

  2. The variables that are part of the struct are called members.

  3. We use the member selection operator(which is a period)

  4. Structs can contain other structs

1 Like