IntPoint which is identical to
Horstmann's Point class as defined on Page 657, 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 -I/usr/local/include/cccfiles2 -c IntPoint.cc -o IntPoint.oYou should use the following variables:
CXX = g++ CXXLIBS = LDFLAGS = -g -Wl,-rpath,/usr/local/lib CXXFLAGS = -g -Wall -Werror -I/usr/local/include/cccfiles2Though these variables are more obscure than the ones you used before, they are standard.
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.
main.cc in your Makefile so that
first main.o is generated, and then main.o
and IntPoint.o are linked together. The compilation
commands should read:
g++ -g -Wall -Werror -I/usr/local/include/cccfiles2 -c main.cc -o main.o g++ -g -Wl,-rpath,/usr/local/lib IntPoint.o main.o -lccc -o mainYou'll notice there are several new flags:
-Werror: Don't let me run my program if there are warnings.
-lccc: Link in a pre-compiled version of Horstmann's
code rather than compiling his code myself.
-Wl,-rpath,/usr/local/lib: Helps the loader find
dynamically loaded files. (Don't ask... Just do it.)
.o files and your main executable
only. 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.