structure member

Example by: Ira Oldham, References: Savitch eighth edition, section 10.1; Gaddis seventh edition, section 11.3

The fields in a structure declaration are called members. The corresponding fields in a variable are called member variables. To access the value in a member variable, use the name of the variable, a dot, and the name of the member name.

1  struct Student
2  {
3    int id;
4    char grade;
5  };

6  int main()
7  {
8    Student c;

9    c.id    = 1234;
10   c.grade = 'A';

11   cout << "c.id:    " << c.id    << endl;
12   cout << "c.grade: " << c.grade << endl;

13   return 0;
14 }
c.id:    1234
c.grade: A

The name of the variable, a dot, and the name of the member are used to access the value of the member variable.