I am trying to figure out what I am doing wrong with this printList Function. I am getting the following compiler error:
No operator "<<" matches these operands.
The function is as follows:
void printList(const List& theList)
{
for(Node* i = theList.getFirst(); i != theList.getLast(); ++i)
{
cout << *i << " ";
cout << endl;
}
}
I have the following as well,
#include "List.h"
#include <iostream>
I am thinking my print function is just way off base. Can anyone point me in the right direction?
Here are my classes, I don't have a List::Iterator. What would you suggest?
class List
{
private:
int nodeListTotal;
Node* first;
Node* last;
public:
//Constructor
List();
void push_back(Node*);
void push_front(Node*);
Node* pop_back();
Node* pop_front();
Node* getFirst() const;
Node* getLast() const;
int getListLength() const;
void retrieve(int index, int& dataItem) const;
};
class Node
{
private:
string dataItem;
string dataUnit;
int unitTotal;
Node* next;
public:
//Constructor
Node();
Node(int, string, string);
string getDescription( );
void setDescription(string);
string getQuantityName();
void setQuantityName(string);
int getQuantityNumber();
void setQuantityNumber(int);
Node* getNext( );
void setNext(Node*);
};
Node n; cout << n;. If that doesn't work, then you forgot to defineostream &Node::operator<<(ostream &).