im working on a function for a custom list class that writes all the items of the list to an output file. However i keep getting this
error: no match for 'operator<<' in 'fout << nodePtr->List::Node::myItem'
and error: no match for 'operator<<' in 'fout << ' ''
i think ive had this problem before but i cant remember whats wrong with it.
#include "List.h"
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <cassert>
void List::writeTo(const string& fileName) const {
ifstream fout( fileName.c_str() );
assert(fout.is_open() );
Node *nodePtr = myFirst;
for (unsigned i = 0; i < mySize; i++) {
fout << nodePtr->myItem;
fout << ' ';
nodePtr = nodePtr->myNext;
}
fout.close();
}