0

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

Edited by jgelderloos: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by tkud
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.