Answer:
- using namespace std;
- struct aaa {
- int m;
- int nn;
- };
- struct bbb{
- struct aaa myfield;
- int sum;
- };
- struct bbb myvar;
- int main()
- {
- myvar.sum =44;
- myvar.myfield.nn = -17;
-
- cout<<myvar.sum<<"\\";
- cout<<myvar.myfield.nn<<"\\";
- return 0;
- }
Step-by-step explanation:
Given two data structures (Line 2-9), we can set the value of 44 to field of sum structure variable myvar by using a dot syntax
myvar.sum = 44
To assign value to field of nn of structure in myvar, we need to access the myfield of myvar and then followed by nn. Hence, the statement shall be
myvar.myfield.nn = -17
In short the we can always use the dot syntax the access the value of an inner field of a particular data structure.