CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    8

    Pass a handle to a function

    codeguru forum,

    Visual C++ 2010

    This is all very new to me.

    I'm using SFML with Visual C++ and need to pass a handle to
    a function. I've tried to find this on the web with no luck.

    The handle happens to be a sprite defined as:
    sf::Sprite Numbers(MyNumbers);

    Now I want to pass "Numbers" to a function.

    -
    -
    getFrame(Numbers);
    -
    -


    ???? getFrame(??????)
    {
    Numbers.SetSubRect(sf::IntRect(0,0,63,63));
    return ????
    }

    How do I do this?

    Thanks for any reply.
    jerryd

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Pass a handle to a function

    Quote Originally Posted by jerry_d View Post
    I'm using SFML with Visual C++ and need to pass a handle to
    a function.
    Whatever framework you use you have to use types provided by the framework.

    I've tried to find this on the web with no luck.
    In case the framework's on-line documentation is not enough, you always may inspect samples the framework site provides.

    ???? getFrame(??????)
    {
    Numbers.SetSubRect(sf::IntRect(0,0,63,63));
    return ????
    }
    Considering this snippet, it seems to me you need to get back to your C++ lessons covering functions and data types.

    Code:
    RETURN_TYPE getFrame(PARAMETER_TYPE parameterVariable)
    {
    Numbers.SetSubRect(sf::IntRect(0,0,63,63));
    return returnValue;
    }
    One of the very basic programming skills is ability to read code/documentation and deduce data types to be used as function parameters and return values, as well as design safe data type casts/transformations for passing data to and from the function if required. Without the skill you're not able to move forward.
    Last edited by Igor Vartanov; May 6th, 2013 at 03:06 AM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured