I am trying to develop a function in a linked list that outputs in a specific manner however I am getting compile errors.
Tis is the code:
listelement.h
virtual void out(ofstream& myfile) = 0;
list.h
includes listelement.h
void OutList(ofstream& myfile);
list.cc
includes list.h
void List::OutList(ofstream &myfile){
ofstream file;
file.open("tris.dat");
if(myfile.is_open()){
ListElement *current;
for (current = head; current != NULL; current = current->next){
current->out(myfile);
}
}
else
cerr << "Unable to open tris.dat" << endl;
file.close;
}
error: statement cannot resolve address of overloaded function
which is in the line of file.close in list.cc
Please help?!