473,786 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1430

"uli" <NO********@nur fuerspam.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::*func d)(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
4618
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 variables". However, this doesn't seem entirely correct. It also doesn't mention whether static member functions can access protected and private member data and methods (and I couldn't spot this in the FAQ). I have a class row<Row> which derives from...
4
2499
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
1534
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. class A { public: void f(int,float); }; class B : public A
4
1380
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> { public: void write (ofstream &filename, format_type format, int start, int end); };
2
1829
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
3356
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
7
2117
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 ----------------------------------------------------------------------------- This is a consortium of ideas from another thread on topic ----------------------------------------------------------------------------- One of the big issues of organizing items within a class, is there are many...
16
2590
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 totally_isolated(Iterator& it) { //how do I find out if it points to the end node? }
8
5744
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 private methods in the same class as method arguments. For example, if Public method Foo() calls private method Bar(), and if Bar() uses member variable m_MyVariable, I declare the private method with the signature: private void Bar(SomeType...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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 we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.