The code is too long so I posted the sections that I have problems with:
Here is the error message that I get on the build log:
In file included from C:\Martin\MalikDownloads\Chapter 5 Source Code\myDoublyLinkedList\main.cpp:2:0:
C:\Martin\MalikDownloads\Chapter 5 Source Code\myDoublyLinkedList\doublyLinkedList.h:22:12: error: 'ostream' does not name a type
C:\Martin\MalikDownloads\Chapter 5 Source Code\myDoublyLinkedList\doublyLinkedList.h:155:1: error: 'ostream' does not name a type
here is the code:
1 2 3 4 5 6
template <class Type>
class doublyLinkedList
{
friend ostream& operator<<(ostream&,
const doublyLinkedList<Type>&);
//Overload the stream insertion operator
The above code is from the header file: doublyLinkedList
Here is the definition:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
template<class Type>
ostream& operator<<(ostream& osObject,
const doublyLinkedList<Type>& list)
{
nodeType<Type> *current; //pointer to traverse the list
current = list.first; //set current to point to
//the first node
while(current != NULL)
{
cout<<current->info<<" "; //output info
current = current->next;
}//end while
return osObject;
}
What frustrates me is that this code is exact as it is in the textbook (Data Structures using C++) written by DS Makil