First of all, I'm using MSVS 2005 standard edition. I haven't downloaded or acquired any additional libraries or tools, just what gets installed with the studio by default. Also, I'm using C++ and started the problem projects as an empty CLR project.
Currently I've had several data structure assignments that required me to make class templates for linked lists, stacks, queues, etc. As a feature of these structures, I like to overload the insertion operator (<<) so that it's simpler to output the entire structure. I've followed everything mentioned from my text books, and even resorted to copying an entire example word for word, and the problem still persists.
And all of my files include the iostream header file and the usingnamespace std; statement. And the function definition is in the same header file as the class definition.
In the class template definition, my prototype for overloading the operator looks like this:
Expand|Select|Wrap|Line Numbers
- friend ostream& operator<<(ostream&, const linkedQueue<Type>&);
Expand|Select|Wrap|Line Numbers
- template<class Type>
- ostream& operator<<(ostream& outPut, const linkedQueue<Type>& thisQueue)
- {
- //makes a pointer to the first element in the queue
- queueNode<Type> *current;
- current = thisQueue.first;
- //steps through the elements of the queue without
- //changing anything.
- while (current != NULL)
- {
- //outputs the data stored in the current node
- outPut << current->data << endl;
- //moves current to the next node
- current = current->next;
- }
- return outPut;
- }//end insertion overload
Expand|Select|Wrap|Line Numbers
- cout << object;
main.obj : error LNK2028: unresolved token (0A00029B)
main.obj : error LNK2019: unresolved external symbol
(project path and name).exe : fatal error LNK1120: 2 unresolved externals
I'd just like to know how to get the insertion operator to work with class templates.
I appreciate any help I receive.