Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with templatized overloaded operator ()

Reply
Thread Tools

Problem with templatized overloaded operator ()

 
 
StephQ
Guest
Posts: n/a
 
      03-11-2007
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

 
Reply With Quote
 
 
 
 
amparikh@gmail.com
Guest
Posts: n/a
 
      03-11-2007
On Mar 11, 12:43 pm, "StephQ" <(E-Mail Removed)> wrote:
> 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);

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in calling an overloaded operator= from inside anotheroverloaded operator= in C++ Afshin C++ 0 08-12-2011 12:19 PM
Problem in calling an overloaded operator= from inside anotheroverloaded operator Afshin C++ 0 08-12-2011 12:01 PM
Problem of overloading operator - templatized kausikd C++ 0 08-06-2010 05:54 AM
Pointer to templatized, overloaded member functions mrstephengross C++ 2 07-02-2007 09:37 PM
Invoking templatized base class constructor from templatized derived class constructor mrstephengross C++ 5 05-18-2005 07:12 PM



Advertisments