structure process

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

You can use the dot notation to access the data from a structure variable, and process the data.

1  struct TwoNumbers
2  {
3    double a;
4    double b;
5  };
6  int main(void)
7  {
8    double result;
9    TwoNumbers x;
10   x.a = 4.3;
11   x.b = 6.5;
12   result = x.a + x.b;
13   cout << "Result: " << result << endl;
14   return 0;
15 }
Result: 10.80

Member values can be set, changed, or used by accessing them using the dot notation.