473,472 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

pass pointer to a thread function ?

hi,

i would like to pass a pointer to a thread function to a class.

The function in my code that i would like to get the address of, and pass it
to a class function is:

DWORD ServiceExecution(LPDWORD param)

And i would like to somehow send the address to a class function, similar to
this:

MyClass.ServiceExe (ServiceExecution):

Can this be done ? i have abit troubles getting it working - i remember that
i in the early years in normal C could do this fairly easy - but it has
really slipped my mind how the syntax is, and if its possible at all...

hope you can help !


Jul 23 '05 #1
3 3083
"mandatory" <ok*****@nptklooohs.ru> wrote...
i would like to pass a pointer to a thread function to a class.

The function in my code that i would like to get the address of, and pass
it to a class function is:

DWORD ServiceExecution(LPDWORD param)

And i would like to somehow send the address to a class function, similar
to this:

MyClass.ServiceExe (ServiceExecution):

Can this be done ?
Not if the class function is a non-static member. See the FAQ, section 33.
[..]


V
Jul 23 '05 #2
"Victor Bazarov"

Not if the class function is a non-static member. See the FAQ, section
33.
[..]


V

hi victor !

thanks, but im not completely sure, but i think you might have misunderstood
me.

My goal isnt to start a memberfunction as a thread, im fully aware that this
has to be a static function outside the class (and then there are some ways
of make it "feel" its inside the class).

My goal is merely to pass on a address of a (static/global) function to a
class-member-function - like GetProcAddress() but just not from a library.
Jul 23 '05 #3
"mandatory" <ok*****@nptklooohs.ru> wrote...
"Victor Bazarov"

Not if the class function is a non-static member. See the FAQ, section
33.
[..]


V

hi victor !

thanks, but im not completely sure, but i think you might have
misunderstood me.

My goal isnt to start a memberfunction as a thread, im fully aware that
this has to be a static function outside the class (and then there are
some ways of make it "feel" its inside the class).

My goal is merely to pass on a address of a (static/global) function to a
class-member-function - like GetProcAddress() but just not from a library.


OK, I probably did misunderstand you. What problem do you have, then?

Your member function has to accept a pointer to a function as its argument
and when you pass it a function, it decays to a pointer to that function,
and everything is peachy.

If section 33 doesn't apply to your problem (which I admit is likely),
then you need to give FAQ 5.8 a try.

V
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
12
by: Huskier | last post by:
Hi all: I want to pass a class-member function to pthread_create, and my code is in the following, but I don't know how to pass myobj.thread_function to pthread_create function. #include...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
2
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
4
by: S. | last post by:
Hi all, I have the requirement that I must pass-by-reference to my function addStudent() and getAge() functions where my getAge() function is within the addStudent() function. I am able to...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
17
by: Daniel | last post by:
When I use the CreateThread API method, what do I need to do when I want to pass more than one parameter where LPVOID lpParameter is passed? Daniel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.