Re: problem using template
you should replace the 10th line with
Code:
QueueItem<Type>* next;
because the pointer to the next node should be of type QueueItem<Type>, not of type of its value.
Re: problem using template
thanks, but in this case I've other type of problem:
Code:
error C2059: syntax error : '<'
error C2238: unexpected token(s) preceding ';'
Code:
template <class Type>
class Queue {
private:
class QueueItem {
private:
public:
Type value;
QueueItem<Type>* next; //problem
QueueItem(Type t) : value(t) {next=0;}
~QueueItem();
};
Re: problem using template
Re: problem using template
hi Do anyone know how pass Queue (by referece) to a funzion (in these 2 case)? thanks
Code:
void populate(Queue<int>& ll){
}
Queuet<int,20>* l = new Queue<int,20>;
//Queue<int>* l = new Queue<int>;
populate(l);
Re: problem using template
Re: problem using template
1.
Code:
error C2664: 'populate' : cannot convert parameter 1 from 'Queue<Type,size>' to 'Queue<Type> &'
with
[
Type=int,
size=20
]
and
[
Type=int
]
2. Could be possible define my own iterator on the queue in the way that I can do this:
Code:
Queue<int,20>::_iterator it;