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();
}

well glad i figured it out before anyone else did. i declared it as ifstream when its supposed to be an ofstream

Good for you , so mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.