#include //for class ofstream #include //for the macros EXIT_SUCCESS and EXIT_FAILURE using namespace std; //This C++ program creates an output file named outfile.txt //in the current directory. void f(); //The function declaration announces the name of the function. int main() { f(); return EXIT_SUCCESS; } void f() //The function definition creates the function. { ofstream outfile {"outfile.txt"}; //The constructor opens the file. outfile << "Morning.\n"; //Use outfile the way we use cout. outfile << "Noon.\n"; outfile << "Night.\n"; } //The destructor closes the file.