473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

pointing to a member function/method within another function

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
3 1416

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
4
by: Jian H. Li | last post by:
Hello, What's the essential differences between the two ways of "class::member" & "object.member"(or object_pointer->member)? class C{ public: void f() {} int i; };
12
by: akiriwas | last post by:
The subject basically says what I am having trouble with. For an example lets say I have a class A which has a function f. I then also have a class B which inherits from A and has a function g. ...
4
by: Alan | last post by:
I have a class, "event_list", derived from the template class "vector." I extended it with a method, "write" for this new class. Here's its definition: class event_list : public vector<Event> {...
2
by: Christoph Boget | last post by:
Let's take the following class: class MyClass { private int privateVar; public int PublicVar { get { return privateVar; } } public MyClass() {}
8
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
16
by: mailforpr | last post by:
How do I do that? The thing is, the only information I have about the iterator is the iterator itself. No container it is belonging to or anything. Like template<Iteratorvoid...
8
by: David Veeneman | last post by:
Should a member variable be passed to a private method in the same class as a method argument, or should the method simply call the member variable? For years, I have passed member variables to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.