calling class instances and their methods

S

spohle

hi,

i created an instance of a my own class which has methods and all. now
i get an outside function called, which is unfortunatly not aware of
the instace at all (i don't control how this outside function is
called). but i would like to get access back to my instance and it's
methods.

is there any clean way of doing this ?

thanks in advance
 
G

Gabriel Genellina

i created an instance of a my own class which has methods and all. now
i get an outside function called, which is unfortunatly not aware of
the instace at all (i don't control how this outside function is
called). but i would like to get access back to my instance and it's
methods.

I don't understand well. Do you want to call a method on your object,
from inside that external function? Can you modify its code?
 
E

Erik Johnson

spohle said:
hi,

i created an instance of a my own class which has methods and all. now
i get an outside function called, which is unfortunatly not aware of
the instace at all (i don't control how this outside function is
called). but i would like to get access back to my instance and it's
methods.

is there any clean way of doing this ?

thanks in advance


Ummm... I'm not exactly sure what you mean by "an outside function", but
let's refer to that function as f(). Are you saying you want to re-implement
f() to use your new object but don't want to (or can't) change calls to f()?

If so, then you can either use a global reference to your new object if
it is the sort of thing you want to keep around between invocations of f()
(i.e., create your object somewhere and then save in a scope that f() can
access). Otherwise, you can simply instantiate your object inside of f() as
a local variable and use it.

If you mean something else, I guess you will have to clarify.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top