mickey
18th November 2006, 03:37
hi, I'm coding the queue of Primer book (template chapter). but I've a prob.
error C2440: '=' : cannot convert from 'QueueItem<Type> *' to 'int *'
with
[
Type=int
]
template <class Type> class Queue;
template <class Type>
class QueueItem {
private:
friend class Queue<Type>;
public:
Type value;
Type* next;
QueueItem(const Type& t) : value(t) {next=0;}
~QueueItem();
};
template <class Type>
class Queue {
private:
QueueItem<Type>* tail;
QueueItem<Type>* head;
public:
Type& remove();
void insert(const Type&);
void print();
bool empty() const {return (head == 0);}
Queue();
~Queue();
};
template <class Type>
void Queue<Type>::insert(const Type& value) {
QueueItem<Type>* p = new QueueItem<Type>(value);
tail->next = p; //here problem
tail = p;
}
How to solve it? Type should be int when i'm go inside insert method.....
thanks
error C2440: '=' : cannot convert from 'QueueItem<Type> *' to 'int *'
with
[
Type=int
]
template <class Type> class Queue;
template <class Type>
class QueueItem {
private:
friend class Queue<Type>;
public:
Type value;
Type* next;
QueueItem(const Type& t) : value(t) {next=0;}
~QueueItem();
};
template <class Type>
class Queue {
private:
QueueItem<Type>* tail;
QueueItem<Type>* head;
public:
Type& remove();
void insert(const Type&);
void print();
bool empty() const {return (head == 0);}
Queue();
~Queue();
};
template <class Type>
void Queue<Type>::insert(const Type& value) {
QueueItem<Type>* p = new QueueItem<Type>(value);
tail->next = p; //here problem
tail = p;
}
How to solve it? Type should be int when i'm go inside insert method.....
thanks