469,299 Members | 2,050 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

calling class instances and their methods

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

Mar 26 '07 #1
2 945
On Mar 26, 12:00 pm, "spohle" <spo...@gmail.comwrote:
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?

--
Gabriel Genellina

Mar 26 '07 #2
"spohle" <sp****@gmail.comwrote in message
news:11********************@e65g2000hsc.googlegrou ps.com...
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.
Mar 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Kerry Neilson | last post: by
2 posts views Thread by Krzysztof Stachlewski | last post: by
12 posts views Thread by Andrew Jaffe | last post: by
3 posts views Thread by Ray Cassick \(Home\) | last post: by
16 posts views Thread by A_PK | last post: by
8 posts views Thread by Jackson | last post: by
9 posts views Thread by nik | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.