Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
About Us Register FAQ Members List Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old April 5th, 2004   #1 (permalink)
General of Tangerines
 
RZetlin's Avatar
 
Join Date: Jun 2001
Location: Defending the Sea
Posts: 3,885
Question C++ passing current object to function

I have an object where I have to pass itself to another function not in the class. How would I do this? "This" doesn't work. How do you pass the current object to another function?

Eg.

Class HumanPlayer
{

string SomeFunction(this) --Referring to current object (Doesn't work!)
}
__________________


AMD Athlon 64 3700+ | 2 GB RAM | XFX Nvidia 6800 GS 256 MB XXX Edition | Win XP Pro SP2
RZetlin is offline   Reply With Quote
Old April 5th, 2004   #2 (permalink)
Puchiko-nyu!
 
kairi00's Avatar
 
Join Date: Jul 2001
Location: 49° 11' N 123° 10' W
Posts: 2,854
'this' is a pointer, so you'll need to declare SomeFunction to accept a pointer instead.

SomeFunction(HumanPlayer* x).

Then you can call SomeFunction(this).

PS: Don't forget to change x.SomeMethod to x->SomeMethod as well!
__________________
"Not every ejaculation deserves a name."

--- George Carlin
kairi00 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:40.

© 2006 - 2008 Emu Forums | About Emu Forums | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.7.0 Release Candidate 3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5