Integer point class

For this lab, you may wish to refresh your memory on using g++ and using makefiles.

  1. Open a new directory.

  2. Implement the class IntPoint which is identical to Horstmann's Point class as defined on Page 657, with two exceptions:

    You should have a header file with declarations in IntPoint.h and definitions in 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.

  3. Write a Makefile to compile your to write an IntPoint.o. The compilation command will be:
    g++ -g -Wall -Werror   -c -o IntPoint.o
    You should use the following variables:
    CXX = g++
    CC = $(CXX)
    LDFLAGS = 
    CXXFLAGS = -g -Wall -Werror
    There is one new option "-Werror" which says, don't let me run my program if there are any warnings.

  4. Add another rule to the end of your makefile:
    	rm -f *~ \#* *.o MY_PROGRAM_NAME
    This says, ``If I type make clean remove all of the emacs backup files ( and, remove all the object files (prog.o), and remove my executable program (clock or logbook or whatever).

  5. Write a very short 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
    g++ main.o IntPoint.o -o main
    The first turns your into a main.o. The second turns your two .o's into an executable main which you can run.

  6. Include compilation of in your Makefile so that first main.o is generated, and then main.o and IntPoint.o are linked together.

  7. After getting your Makefile and program to work, try typing
    make clean
    to 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!

  8. Check off: Don't forget to get checked off. You should have Makefile in one buffer and the *compilation* buffer in the other. We'll also look at your .cc and .h files.