-> operator and its uses and benefits

This is a discussion on -> operator and its uses and benefits within the C++ Programming forums, part of the General Programming Boards category; Hello all, I have a question regarding the C++ operator -> What does it do? Can somebody please help me ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    92

    -> operator and its uses and benefits

    Hello all,
    I have a question regarding the C++ operator -> What does it do? Can somebody please help me understand it more clearly. If possible can you also guide me with an online link or two to further my understanding of the subject.
    Thanks

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    Can you be a little more clear? That is used for normal pointer dereference and also can be overloaded to create "smart pointers", forwarding tasks from "envelope" to "letter" classes, not to mention for whatever else you may think of...
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    If you want a link, then try a search....if you want a book, then invest in More Effective C++ by Scott Meyers....he devotes a chapter to smart pointers and describes how to overload operator* and operator-> and what you should/shouldnt do when doing so

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    These two statements are often equivalent:
    Code:
    a->b;
    (*a).b;
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21