|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
General of Tangerines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2001
Location: Defending the Sea
Posts: 3,885
|
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!) } |
|
|
|
|
|
#2 (permalink) |
|
Puchiko-nyu!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|