I really do not understand why I am getting an error here on this line.
Because on the other lines before it I do not get an error.
Here is the error:
114 16 C:\Martin\MalikChapter8\main.cpp [Error] no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'linkedListType<int>')
#include <iostream>
#include "linkedList.h"
#include "queueLinked.h"
usingnamespace std;
int main()
{
linkedListType<int> list;
int num;
cout<<"Enter numbers ending wiht -999" <<endl;
cin >> num;
while(num != -999)
{
list.insertLast(num);
cin >> num;
}
cout << endl;
cout<<"List: "<<list<<endl;
cout<<"Length of the list: "<<list.length() <<endl;
cout<<"Enter all occurrences of number to be deleted: ";
cin >> num;
cout << endl;
list.deleteAll(num);
cout<<"List after deleting all occurrences of "<< num << endl;
cout<<list<<endl;
cout<<"Length of the list: "<<list.length()<<endl;
list.deleteSmallest();
cout<<"List after deleting the smallest element" << endl;
cout<<list<<endl;
cout<<"Length of the list: "<<list.length() <<endl;
return 0;
}
The line number on your error message doesn't seem to match the line numbers in the code you've posted. Can you indicate exactly which line of code is causing the error?
So the error is on the very first line where you try to stream the object? In that case, yeah, you either haven't defined an << operator for your class, or you've done it wrong. Since you haven't shown us the definition of the class, we can't know which. (Why did you think withholding that code would be a helpful thing to do?)
The compiler can't magically know how you want to output your class. You have to tell it. You do that by defining the << operator for the class.