By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,407 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,407 IT Pros & Developers. It's quick & easy.

pointing to a member function/method within another function

P: n/a
uli
Hi all,
I've learned native C and I'm trying to write now in C++. I want to use a
simple routine from the "Numerical Recipes in C" for using a Newton-Raphson
Method within my c++ class. The Newton-Raphson function for finding roots is
called:
float rtsafe(void (*funcd)(float, float *, float *), float x1, float x2,
float xacc)

'funcd' is the pointer to an external function as common in C. But since I
want to use it with a member function of my class for computing its roots, I
think I can't do that, because member functions are adressed relative to my
class.

Could anyone please give me some hints what I have to do, so that I can use
an external function like this and give it member functions for computation.
(Please apologise my bad style talking about coding...)

Thanx a lot,
uli
--
For reply remove NOSPAM_ from email-adress

Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"uli" <NO********@nurfuerspam.de> wrote in message
news:c7**********@newssrv.muc.infineon.com...
Hi all,
I've learned native C and I'm trying to write now in C++. I want to use a
simple routine from the "Numerical Recipes in C" for using a Newton-Raphson Method within my c++ class. The Newton-Raphson function for finding roots is called:
float rtsafe(void (*funcd)(float, float *, float *), float x1, float x2, float xacc)

'funcd' is the pointer to an external function as common in C. But since I
want to use it with a member function of my class for computing its roots, I think I can't do that, because member functions are adressed relative to my class.

Could anyone please give me some hints what I have to do, so that I can use an external function like this and give it member functions for computation. (Please apologise my bad style talking about coding...)


Hopefully this gives the idea.

float rtsafe(MyClass* my_class, void (MyClass::*funcd)(float, float *,
float *), float x1, float x2, float xacc)
{
(my_class->*funcd)(a, b, c);
}

john
Jul 22 '05 #2

P: n/a
uli wrote:

Hi all,
Could anyone please give me some hints what I have to do, so that I can use
an external function like this and give it member functions for computation.
(Please apologise my bad style talking about coding...)


Check the FAQ

http://www.parashift.com/c++-faq-lit...o-members.html
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #3

P: n/a
uli
Thank you a lot for your quick responses. I think that are the Infos I
need...
uli

--
For reply remove NOSPAM_ from email-adress
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.