hi...
this is regarding print to a text file...i can print to a console window but when i try to print the same thing to a text file...i don't get anything in the text file after execution...
i have a class called Decision...just concerned code here...
Code:
class Decision {
friend ostream& operator<<(ostream &o, Decision &d); // Print out the tree
Node *root; // The top of the decision tree
};
this is how i print out the tree structure to the console window:
Code:
// Print out the tree
ostream& operator<<(ostream &o, Decision &d)
{
d.root->print(0);
return o;
}
then in the main function:
Code:
Decision decision("sunburn.examples");
decision.build_tree(); //to build a decision tree
cout << decision;
ofstream fout; //to write out to an output file
fout.open ("outputfile.txt");
fout << decision << endl;
fout << flush;
fout.close();
so basically cout << decision <<endl; works fine but the fout << decision bit does not print anything to the text file...
any ideas?
Farooq