1. Why do we need structs?
We need structs in order to group multiple individual variables of different data types together. This make it easier to pass information more easily to a function and declare faster several “entities”.
2. What are members in a struct?
The members are the variables inside the struct that define it. For example declaring an employee in a program might include its age, wage, department etc…
3. How do you access a member inside a struct?
Accessing a member in a struct is done by using the name of variable that is the struct, and then appending the member selection operator, which is simply a period, and then the member previously declared in the struct. For example, I declare my struct:
Then I declare a variable, which type is the struct I created:
Then I access the members like so:
joe.id = 14;
4. What is a nested struct?
A nested struct is a struct within a struct
Employee CEO; // Employee is a struct within the Company struct