int main(int argc , char* argv[]) { if (argc == 1) { printUsage (&cout , argv [0]); return 0; } Cat MyCat (argc , argv); int nPos = isArg (argc , argv); ostream* Out = NULL; ofstream OutFile; if (nPos != -1) { string Path = getFile (argv [nPos]); OutFile.open (Path.c_str () , ios::app); Out = &OutFile; } else { Out = &cout; } MyCat.print (Out); if (nPos != -1) { OutFile.close (); } return 0; }