friend template overload problem

Discussion in 'C++' started by Helmut Jarausch, Mar 21, 2007.

  1. Hi,

    could anybody please explain to me what's wrong with
    the following code

    template <typename INT,INT P> class Zp;

    template <typename INT,INT P>
    Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b);

    template <typename INT,INT P>
    class Zp {

    public:
    Zp operator-() const; // that's the unary operator -
    // vvvvvvvvvvvv this is binary operator -
    friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b);
    // this produces
    // error: declaration of 'operator-' as non-function
    // error: expected ';' before '<' token
    };


    Many thanks for your help,

    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
    Helmut Jarausch, Mar 21, 2007
    #1
    1. Advertising

  2. Helmut Jarausch

    Sarath Guest

    On Mar 22, 7:02 am, Helmut Jarausch <> wrote:
    > Hi,
    >
    > could anybody please explain to me what's wrong with
    > the following code
    >
    > template <typename INT,INT P> class Zp;
    >
    > template <typename INT,INT P>
    > Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b);
    >
    > template <typename INT,INT P>
    > class Zp {
    >
    > public:
    > Zp operator-() const; // that's the unary operator -
    > // vvvvvvvvvvvv this is binary operator -
    > friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b);
    > // this produces
    > // error: declaration of 'operator-' as non-function
    > // error: expected ';' before '<' token
    >
    > };
    >
    > Many thanks for your help,
    >
    > Helmut Jarausch
    >
    > Lehrstuhl fuer Numerische Mathematik
    > RWTH - Aachen University
    > D 52056 Aachen, Germany


    Seems the <> is not required.
    friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b);
    Sarath, Mar 22, 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. Piotre Ugrumov
    Replies:
    3
    Views:
    362
    Nick Hounsome
    Jan 25, 2004
  2. Gianni Mariani
    Replies:
    5
    Views:
    964
    Jerry Coffin
    Jan 18, 2005
  3. Teddy
    Replies:
    5
    Views:
    9,543
    Swampmonster
    Jun 10, 2005
  4. A L
    Replies:
    1
    Views:
    504
    Alf P. Steinbach /Usenet
    Aug 25, 2010
  5. Ying-Chieh Liao

    function overload (not operator overload)

    Ying-Chieh Liao, Oct 11, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    237
    Sherm Pendley
    Oct 11, 2004
Loading...

Share This Page