hello,
i am trying to read from a file until EOF, and print details to the screen.
it seems to print extra stuff at the end.
below is my code
and the printout that i actually get when i run my prog is (without the hashes)..Code:list<Things*> i; ifstream x ("file.txt"); while(!x.eof()) { Things* temp = new Things; x.getline(one); x >> two; x >> three; temp->set_one(one); temp->set_two(two); temp->set_three(three); i.push_back(temp); } ostream& Foo::printAll(ostream& stream) { list<Things*>::iterator a; for(a = i.begin(); a != i.end(); ++a) stream << (**a).print_details(stream) << endl; return stream; } ostream& Bar::print_details(ostream& stream) { stream << "ONe: " << get_one() << endl << "Two: " << get_two() << endl << "Three: " << get_three() << endl << endl; return stream; }
###################
One: eeny
Two: meeny
Three: miny
0x804d1bc
One:
Two: meeny
Three: miny
0x804d1bc
###################
and my file contains (without the hashes)
###################
eeny
meeny miny
###################
can anyone see why its printing it twice and those funny address values aswell?



LinkBack URL
About LinkBacks



rint_details() you reference get_one(), get_two() and get_three() as if they were of type Bar.....is this an inherited class?