473,396 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

friend template overload problem

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
1 1442
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Paul MG | last post by:
Hi Template partial specialization always seems like a fairly straightforward concept - until I try to do it :). I am trying to implement the input sequence type (from Stroustrup section...
3
by: 胡岳偉(Yueh-Wei Hu) | last post by:
Hi all, I have 2 questions about template function as friends in template classes. I don't know why, and hope someone could help me. ...
0
by: Yueh-Wei Hu | last post by:
Victor Bazarov <v.Abazarov@comAcast.net> wrote in message news: ============================================================== > > Question 1: > >...
1
by: paidojoao-groups | last post by:
Given this code: #include <iostream> #include <string> class timestamp { public: timestamp() {
5
by: James Aguilar | last post by:
Hello, all. I saw this in the provided code of a lab that I have due in a couple of weeks in my algorithms class. It compiled fine in g++ but did not compile with the VC++ compiler. It does...
5
by: Gianni Mariani | last post by:
Can anyone enligten me why I get the "ambiguous overload" error from the code below: friendop.cpp: In function `int main()': friendop.cpp:36: ambiguous overload for `std::basic_ostream<char,...
4
by: CrimzonRJ | last post by:
Theoretically, how are you supposed to overload << as friend to a template class? I keep getting an 'unresolved extern symbol' error. Is this even a smart thing to do?
3
by: mrstephengross | last post by:
Hi folks... I've been sifting through archived postings on this, but haven't quite found an answer yet. I've got a templated stand-alone function: template<typename Tvoid access(const T & t) { ;...
4
by: fdmfdmfdm | last post by:
I have the following code: #include <iostream> #include <cstdlib> #include <cassert> using namespace std; template <class T> class Stack{ public: enum{DefaultStack = 10, EmptyStack = -1};
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.