On Apr 1, 9:55*pm, Victor Bazarov <v.baza...@comcast.invalid> wrote:
> On 4/1/2011 9:15 PM, Nephi Immortal wrote:
>
>
>
>
>
> > * *Please look at my code below. *You may notice operator->* with
> > comments. *Figure out why it does not make any sense.
>
> > struct data;
> > typedef void ( data::*pGo )();
>
> > struct data {
> > * *char x;
> > * *char y;
> > * *pGo Go;
>
> > * *void Run() {
> > * *}
> > };
>
> > struct storage {
> > * *data *pData;
>
> > * *data *operator->() {
> > * * * * * *return pData;
> > * *}
>
> > * *storage&operator->*( pGo p ) {
> > * * * * * *( pData->*p )();
> > * * * * * *return *this;
> > * *}
> > };
>
> > int main()
> > {
> > * *data d; storage s;
> > * *s.pData =&d;
> > * *s->x = 1; s->y = 2; s->Go =&data::Run;
>
> > * *( d.* d.Go )(); // OK
> > * *( d.* s->Go )(); // OK
>
> > * *s.operator->*( s->Go ); // ??? Works fine
> > * *s->*( s->Go ); // ??? Works fine
>
> > * *( s->* s->Go )(); // Should be, but does not work!
>
> What do you mean by "does not work"? *Does it compile? *If not, what's
> the error message, what in it is unclear? *If it does compile, do you
> get an error when running?
>
> Have you checked operator precedence? *Can you place the parentheses in
> the last expression to indicate how you think it should be evaluated?
> Does it "work" after that? *What's different (if anything) when you add
> parentheses?
Victor,
You asked the same questions. I searched using google operator->*
across websites. There are a lot of operator->, but nothing showed
operator->*. There is no book mentioned it either.
I can say operator->* is rarely used. Please do a favor for me. Do
your homework to do research? Okay? If you succeed, the information
should be added to the book. You will be author as C++ book writer.
>
>
>
> > * *return 0;
> > }
>
> V
> --
> I do not respond to top-posted replies, please don't ask- Hide quoted text -
>
> - Show quoted text -
|