Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objects and api calls 1

Status
Not open for further replies.

DonQuichote

Programmer
Nov 9, 2001
980
Some API calls require an address of a routine, like a timer call. If I want to encapsulate an API timer in an object, can I use private properties?

The reason I ask this, is that I can imagine that all the properties of an instance exist for each instance, but the methods only exist for each class. Each instance would then call the same methods, but with their own properties. So if I give the address of a method to an API call, is there a way to reach the data of the specific instance I am calling it for?

I am programming in Visual Basic.
 
Hi DonQuichote,
As far as i know (C++) it is not possible to pass method pointers. You can just pass function pointers, i.e. pointers to static member functions. So the functions are independent of any instance.
But you could give your instance (if you want to do so) as an argument to the static member function, so it's possible to use it similar to methods.
I did this by providing a void *tthis pointer as argument in which i passed the respective instance.

Christoph
 
You are right. VB doesn't either. I can only get the address of my only global procedure (runUnitTests), but not the address of a method.

[bugeyed] This would mean that both VB and C++ make it impossible to encapsulate an API timer. Yuk!
 
Well... I am not sure about that, in C++.
You still could use a C style function in your C++ program and declare it as a friend of the class you want to have timers, if access to non-public members is needed.
Have you tried that? [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top