Problem with templatized overloaded operator ()

Discussion in 'C++' started by StephQ, Mar 11, 2007.

  1. StephQ

    StephQ Guest

    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
     
    StephQ, Mar 11, 2007
    #1
    1. Advertising

  2. StephQ

    Guest

    On Mar 11, 12:43 pm, "StephQ" <> 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);
     
    , Mar 11, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrstephengross
    Replies:
    5
    Views:
    613
    Larry I Smith
    May 18, 2005
  2. mrstephengross
    Replies:
    2
    Views:
    613
    mrstephengross
    Jul 2, 2007
  3. kausikd
    Replies:
    0
    Views:
    248
    kausikd
    Aug 6, 2010
  4. Afshin
    Replies:
    0
    Views:
    298
    Afshin
    Aug 12, 2011
  5. Afshin
    Replies:
    0
    Views:
    307
    Afshin
    Aug 12, 2011
Loading...

Share This Page