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

Problem with templatized overloaded operator ()

P: n/a
I can't get this code working:

class Scheme_euler
{
private:
....

public:
....

template<class D, double (D::*drift)(double) const, double
(D::*diffu)(double) const>
void operator ()(Path& thePath, const D& theD) const;
};

Scheme_euler theEu(0, 1, 100); //constructor
theEu<Diff_sine, &Diff_sine::mu, &Diff_sine::sigma>
(thePath, theDiff_sine);

However if I don't overload the operator () but just consider a member
solve function, then using:
theEu.solve<Diff_sine, &Diff_sine::mu, &Diff_sine::sigma>
(thePath, theDiff_sine);
woks fine.

So the problem is in overloading the operator, but I can't understand
where I'm wrong.

Thank you in advance for your help!
StephQ

Mar 11 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mar 11, 12:43 pm, "StephQ" <askmeo...@mailinator.comwrote:
I can't get this code working:

class Scheme_euler
{
private:
....

public:
....

template<class D, double (D::*drift)(double) const, double
(D::*diffu)(double) const>
void operator ()(Path& thePath, const D& theD) const;

};

Scheme_euler theEu(0, 1, 100); //constructor
theEu<Diff_sine, &Diff_sine::mu, &Diff_sine::sigma>
(thePath, theDiff_sine);

However if I don't overload the operator () but just consider a member
solve function, then using:
theEu.solve<Diff_sine, &Diff_sine::mu, &Diff_sine::sigma>
(thePath, theDiff_sine);
woks fine.

So the problem is in overloading the operator, but I can't understand
where I'm wrong.

Thank you in advance for your help!
StephQ

I havent tried the code but just off the back of my mind I recall
similar problems with the function operator.

try the following..

theEu.operator()<Diff_sine, &Diff_sine::mu, &Diff_sine::sigma>
(thePath, theDiff_sine);

Mar 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.