friend template overload problem

H

Helmut Jarausch

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
 
S

Sarath

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);
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top