F
fl
Hi,
I read "C++ Primer", 4th edition. On Chapter 14, page 525, it talks about overloading the arrow operator. I do not understand "then repeat these threesteps". I have check the errata, there is no mistake in this page. These is a link which also mentions steps (but it is still not answers to my questions)
http://stackoverflow.com/questions/10677804/how-arrow-operator-overloading-works-internally-in-c
I rewrite the text here in order the reader can help me.
"When we write
point->action();
precedence rules make it equivalent to writing
(point->action)();
In other words, we want to call the result of evaluating point->action. Thecompiler evaluates this code as follows:
1. If point is a pointer to a class object that has a member named action, then the compiler writes code to call the action member of that object.
2. Otherwise, if point is an object of a class that defines operator->, then point->action is the same as point.operator->()->action, That is, we execute operator->() on point and then repeat these three steps, using the result of executing operator-> on point.
3. Otherwise, the code is in error."
I do not know the last part of item 2. I do not find any snippet code using
->display. I do not find any part mentioning 3 steps. Thus, I cannot solve this myself.
Could you help me out? Thanks,
I read "C++ Primer", 4th edition. On Chapter 14, page 525, it talks about overloading the arrow operator. I do not understand "then repeat these threesteps". I have check the errata, there is no mistake in this page. These is a link which also mentions steps (but it is still not answers to my questions)
http://stackoverflow.com/questions/10677804/how-arrow-operator-overloading-works-internally-in-c
I rewrite the text here in order the reader can help me.
"When we write
point->action();
precedence rules make it equivalent to writing
(point->action)();
In other words, we want to call the result of evaluating point->action. Thecompiler evaluates this code as follows:
1. If point is a pointer to a class object that has a member named action, then the compiler writes code to call the action member of that object.
2. Otherwise, if point is an object of a class that defines operator->, then point->action is the same as point.operator->()->action, That is, we execute operator->() on point and then repeat these three steps, using the result of executing operator-> on point.
3. Otherwise, the code is in error."
I do not know the last part of item 2. I do not find any snippet code using
->display. I do not find any part mentioning 3 steps. Thus, I cannot solve this myself.
Could you help me out? Thanks,