Thread: This

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    Post This

    can anyone give me a good example of implementing the 'this' pointer in functions and methods for classes?

    if the answer is yes, cheers! http://www.cprogramming.com/cboard/i...ons/icon14.gif

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Overloaded assignment operator -

    const SomeClass& operator=(const SomeClass& rhs)
    {
    //Check for self assignment
    if(&rhs==this)
    return;
    else
    //Copy stuff

    //return so chaining is possible
    return *this
    }
    zen

Popular pages Recent additions subscribe to a feed