Hey guys, I've got a couple of questions that are really stumping me on my review and I'm having a hard time finding the answer in my book. Could someone help me out? Here are the first two of the series:
Given the declarations
what is the data type of the expression ptr->next->next->volume?
e) none--the expression is invalid
What part of the questions are you having trouble with? Also, it seems you forgot part of the question on the second, as it's asking to select from a list of identifiers presumably but you didn't include that list.
In a chain of calls, the overall return type is the same as the last call, so for the first question, you should focus on FOO->volume. Therefore, the final type should be the same as the type of volume.
For the second question, remember that dereferenced pointers return a reference to the type they point to. So in the following:
1 2 3
a = *b; //Here *b is of type int
You can use that knowledge combined with what you know about chains of calls to help you figure the type of each option.
For BAR *FOO, *FOO technically returns BAR&, because you should be able to modify the original object that FOO points to and not a copy.