hi i have used the template in my simulation program but it generate the error, my program line of code that generate the error is (these code are in queue.template file)
template <class QueueItem>
queue <QueueItem>::~queue() // line25
{
}
template <class QueueItem>
void queue<QueueItem>::push(const QueueItem& entry) //line 42
{
}
template <class QueueItem>
std::ostream& operator << (std::ostream& out_s, const queue<QueueItem>& q)
{
typename queue<QueueItem> ::Node *QueueCursor; // line 85
// code here
}
ERROR generated are
queue.template:25: error: expected constructor, destructor, or type conversion before '<
queue.template:25: error: expected `;' before '<' token
queue.template:42: error: expected init-declarator before '<' token
queue.template:42: error: expected `;' before '<' token
queue.template:84: error: ISO C++ forbids declaration of `queue' with no type
queue.template: In function `std::ostream& CSCI30l_queue::operator<<(std::ostream&, int)
queue.template:85: error: expected nested-name-specifier before "queue"
queue.template:85: error: expected `(' before '<' token
queue.template:85: error: expected primary-expression before '>' token
queue.template:85: error: `::Node' has not been declared
queue.template:85: error: `QueueCursor' undeclared (first use this function)
queue.template:85: error: (Each undeclared identifier is reported only once for each fun )
queue.template:86: error: `q' undeclared (first use this function)
I could not figure out the problem
here the queue is the class that have the constructor and class itself defined in the queue.h file and this queue.template file is the implementation of the member function defined in the queue.h file