A
Alan Johnson
I set out to make a templated priority queue class, based on
std::vector. I didn't get very far at all before my attempts got cut
short by an error on the following line (see below for context):
std::vector<T>::iterator i ;
My compiler (g++ 2.96, as well as g++ 3.0.4) produce the error: parse
error before `;'
I do not understand why I cannot instantiate an iterator like this.
Replacing 'T' with 'int', 'double' or even something strange like
'std::vector<int> ' works just fine.
Below is the full code, reduced to the point necessary to demonstrate
the error (assume that T is a suitable type to be displayed by cout).
Thanks,
Alan
template <class T>
class pqueue
{
private :
std::vector<T> heap ;
public :
void dump_heap()
{
std::vector<T>::iterator i ;
for (i = heap.begin(); i != heap.end(); i++)
std::cout << *i << std::endl ;
}
} ;
std::vector. I didn't get very far at all before my attempts got cut
short by an error on the following line (see below for context):
std::vector<T>::iterator i ;
My compiler (g++ 2.96, as well as g++ 3.0.4) produce the error: parse
error before `;'
I do not understand why I cannot instantiate an iterator like this.
Replacing 'T' with 'int', 'double' or even something strange like
'std::vector<int> ' works just fine.
Below is the full code, reduced to the point necessary to demonstrate
the error (assume that T is a suitable type to be displayed by cout).
Thanks,
Alan
template <class T>
class pqueue
{
private :
std::vector<T> heap ;
public :
void dump_heap()
{
std::vector<T>::iterator i ;
for (i = heap.begin(); i != heap.end(); i++)
std::cout << *i << std::endl ;
}
} ;