return *this;
  • GGPlayGGPlay April 2008
    this is a thing when i was studing C++

    in the class function we use return *this; for get itself pointer
    so maybe can use for this
    1
    2
    3
    hge->Effect_Free(snd);
    hge->Texture_Free(tex);
    hge->Texture_Free(quad.tex);


    becomes
    1
    2
    hge->Effect_Free(snd)->Texture_Free(tex)->Texture_Free(quad.tex
    )


    in one statement but in some cases will be long.

    just an idea for share , thx

    GGPlay
  • ProfEclipseProfEclipse April 2008
    I'm not sure why you would want to do that. It just makes things less clear. And, since those methods don't return the hge pointer, it wouldn't work anyway.
  • GGPlayGGPlay April 2008
    Yes i know that doesn't work
    but in the Begin C++ programming book
    recomend this use , i just bring up that's idea,
    but in fact i don't know that make less clear,i never have a
    really project worked, so sorry my ignorance :oops:

    but is there any posibility for use?
    like tihs:

    pFont->SetColor(ARGB(255,255,255,0))->SetScale(2.0); ??

    GGPlay
  • ProfEclipseProfEclipse April 2008
    Returning *this is generally only useful for things like operator overloads. That lets you do things like:

    objA = objB + objC;

    For general class methods, it really doesn't make sense to return something just for the sake of returning something.
  • GGPlayGGPlay April 2008
    :lol: thank u very much , that's make me
    more clear the return *this concept;

    If u want , u can delete my post , sorry for spent ur time
    because my silly
  • ProfEclipseProfEclipse April 2008
    No need to apologize. You don't learn if you don't ask!
  • GGPlayGGPlay April 2008
    :o !
  • DANTEDANTE May 2012
    I have seen the C++ can be coded like this for first time.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (0)