Thread: -> operator and its uses and benefits

  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,708
    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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    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