The file that you downloaded is a C++ program.
The last part of the file's name,
cxx
, indicates that the file is a C++ program.
The program, heatwave.cxx
, computes
some information about heating a house,
but the real purpose of the program is to demonstrate what a program
looks like and how to run a program on a machine.
Later, during your reading assignment, you can look at how this program was written. But for now
you will simply see how to run a program such as this one. The first step in running a program is
to run the C++ compiler. A compiler does the task of translating from a programming language
(such as C++) to the low level instructions that a computer actually runs. Our compiler is
Version 2.7 of the Gnu C++ compiler. You can start the compiler from
the black command window by typing this command:
bgi++ -Wall -g heatwave.cxx -o heatwave.exe
In your compilation command,
the -Wall
option instructs the compiler to list all warning messages.
These warning messages usually indicate programming errors, and we'll
forbid most warning messages in your programs. The -g
option
puts extra debugging information into your program.
At the end of the compilation
line, the arguments -o heatwave
indicate that the compiler should put
its result (the "object code") in a file called heatwave.exe. If you don't
specify a location for the object code, then the compiler places its
result in a file named a.exe, which is not a particularly useful name.
Anyway, compile the heatwave program now (as shown above), and then list
your files by typing the command dir
. You should see
something like these files:
08/11/2004 10:23 AM 2,160 heatwave.cxx
01/08/2009 12:27 PM 550,345 heatwave.exe