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

friend template overload problem

P: n/a
Hi,

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

template <typename INT,INT Pclass Zp;

template <typename INT,INT P>
Zp<INT,Poperator-(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,Poperator- <>(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
Mar 21 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mar 22, 7:02 am, Helmut Jarausch <jarau...@skynet.bewrote:
Hi,

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

template <typename INT,INT Pclass Zp;

template <typename INT,INT P>
Zp<INT,Poperator-(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,Poperator- <>(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,Poperator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b);

Mar 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.