CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2009
    Posts
    57

    [RESOLVED] Pass a class as an argument in a member function

    I have a class called player and the member function move. In move, there is a function that needs the player as an argument. How can I pass the player itself as an argument to the function???

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Pass a class as an argument in a member function

    Sounds like you want to pass an object of the player class as an argument.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Sep 2009
    Posts
    57

    Re: Pass a class as an argument in a member function

    Yeah, how can I do it?

  4. #4
    Join Date
    Jun 2008
    Posts
    592

    Re: Pass a class as an argument in a member function

    assuming the function is setup for that, you can use the this keyword or *this
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  5. #5
    Join Date
    Sep 2009
    Posts
    57

    Re: Pass a class as an argument in a member function

    Thanks Joeman, th is exactly what I wanted

  6. #6
    Join Date
    Aug 2005
    Location
    San Diego, CA
    Posts
    1,054

    Question Re: Pass a class as an argument in a member function

    Is move static? Why else would an object need to pass the this pointer to one of its own member functions?

  7. #7
    Join Date
    Sep 2009
    Posts
    57

    Re: Pass a class as an argument in a member function

    It was passing it to an outside function via the member function, but the issue is solved now.

Tags for this Thread

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