In my software engineering studies I have the book "Data Structures using C++" and I am trying to get the exmples from the book to work using visual C++. When I try to compile the code, I get the following linker error:
The error happens on the line: cout << mylist2;
If I comment out this line, it works correctly. The header file is included as an attachment. Please help me solve this problem.
Your problem is explained at this FAQ item. There are different ways to fix it. My usual solution is the following: (Once you read the FAQ you'll understand.)
Code:
//In your list template.
template<class Type>
class linkedListType
{
template <class T> //Use a different name than Type.
friend ostream& operator<<(ostream&, const linkedListType<T>&);
//...
};
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.