IntPoint which is identical to
Horstmann's Point class as described on page 730, with two exceptions:
IntPoint has integer coordinates.
IntPoint won't be able to draw itself on
cwin.
You should have a header file with declarations in
IntPoint.h and definitions in IntPoint.cc
You may wish to refer to the files in
~mc38/labs/point/clock/, which contains the
Clock game from the book split among different files.
g++ -g -Wall -Werror -c -o IntPoint.o IntPoint.ccYou should use the following variables:
CXX = g++ CC = $(CXX) CPPFLAGS = LDFLAGS = CXXFLAGS = -g -Wall -WerrorThere is one new option "-Werror" which says, don't compile my program if there are any warnings.
clean: rm -f *~ \#* *.o MY_PROGRAM_NAMEThis says, ``If I type
make clean remove all of the
emacs backup files (prog.cc~ and #prog.cc#), remove all
the object files (prog.o), and remove my executable program
(clock or logbook or whatever).
main.cc which defines
main() and calls your point class. Your
main will just create a point, move it, and then output
its final coordinates. Don't forget to start
this file with the appropriate #include.
You'll need to update your Makefile to include the following additional compilation commands:
g++ -g -Wall -Werror -c -o main.o main.cc g++ main.o IntPoint.o -o mainThe first turns your
main.cc into a
main.o. The second turns your two .o's
into an executable main which you can run.
main.cc in your Makefile so that
first main.o is generated, and then main.o
and IntPoint.o are linked together.
make cleanto clean up your directory. Type
ls to see
if only critical files remain. Then, remove your two
Makefile actions which create main.o and
IntPoint.o. (The actions are the actual commands
make executes to compile your code. Don't remove the
dependency lists.) Surprisingly, the program should still compile
when you type make!
Makefile in one buffer and the
*compilation* buffer in the other. We'll also look at
your .cc and .h files.