J
James Aguilar
There is a syntax error in this code that I can't figure out.
template <class T>
std:stream &operator <<(std:stream &os, PriorityQueue<T> &q)
{
using namespace std;
//g++ doesn't like the next line, says error before = operator.
vector< HeapNode< T > >::iterator it = q.m_store.begin();
while (it != q.m_store.end()) {
os << *it++ << endl;
}
return os;
}
The actual error message is:
"PriorityQueue.h: In function 'std:stream& operator<<(std:stream&,
PriorityQueue<T>&)':
PriorityQueue.h:228: error: parse error before '=' token"
Any idea what could be causing it? "HeapNode< T >" is valid when used as a
declaration, and if I change the vector declaration to "vector< int >" it
also works (even though q.m_store is not actually a vector of ints but of
Ts).
Thanks,
James
template <class T>
std:stream &operator <<(std:stream &os, PriorityQueue<T> &q)
{
using namespace std;
//g++ doesn't like the next line, says error before = operator.
vector< HeapNode< T > >::iterator it = q.m_store.begin();
while (it != q.m_store.end()) {
os << *it++ << endl;
}
return os;
}
The actual error message is:
"PriorityQueue.h: In function 'std:stream& operator<<(std:stream&,
PriorityQueue<T>&)':
PriorityQueue.h:228: error: parse error before '=' token"
Any idea what could be causing it? "HeapNode< T >" is valid when used as a
declaration, and if I change the vector declaration to "vector< int >" it
also works (even though q.m_store is not actually a vector of ints but of
Ts).
Thanks,
James