Thread: STUPID NEWBIE question...

  1. #1
    Unregistered
    Guest

    Angry STUPID NEWBIE question...

    Okay, the problem here is stupidity... But that is not somthing that can be fixed :/

    So anyways, I'm learning classes... Everything is going just fine and then I get to the section on the this pointer. I think I understand what the this pointer does... But some of the other code I don't understand.

    Code:
    softball& softball::topbat(softball& player)
    {
        if(player.ave > ave)
            return player;
        else
            return *this
    }
    I don't understand the line with '&' in it... I thought '&' was used for memory addresses...

    Help me out please.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297

    Re: STUPID NEWBIE question...

    Originally posted by Unregistered

    Code:
    softball& softball::topbat(softball& player)
    {
        if(player.ave > ave)
            return player;
        else
            return *this
    }
    softball & // the return type
    this means you are returning a softball by reference which basically IS a pointer but it doesn't look that way syntax-wise.

    softball & player // the parameter list
    you are passing in a softball but it doesn't make a copy. It's the pointer but again, doesn't look that way syntax-wise.

    return *this;
    you're dereferencing the this pointer. Again, you're actually passing back "this" object by reference.

    by reference is essentically a dereferenced pointer. you can use the dot operator conveniently
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid newbie question
    By CompiledMonkey in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2004, 12:32 PM
  2. A very stupid newbie question
    By bradleym in forum C Programming
    Replies: 6
    Last Post: 09-14-2002, 04:08 AM
  3. Stupid Question
    By Labelizm in forum Windows Programming
    Replies: 2
    Last Post: 07-24-2002, 04:59 AM
  4. very newbie question: how to copy files
    By webwesen in forum C Programming
    Replies: 26
    Last Post: 04-25-2002, 03:01 PM
  5. Episode II Return Of the newbie : Website IO Question
    By MagiZedd in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 08:58 PM