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 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.

  3. Write a Makefile to compile your IntPoint.cc to write an IntPoint.o. The compilation command will be:
    g++ -g -Wall -Werror -I/usr/local/include/cccfiles2 -c IntPoint.cc -o IntPoint.o
    
    You should use the following variables:
    CXX = g++
    CXXLIBS = 
    LDFLAGS = -g -Wl,-rpath,/usr/local/lib
    CXXFLAGS = -g -Wall -Werror -I/usr/local/include/cccfiles2
    
    Though these variables are more obscure than the ones you used before, they are standard.

  4. Write a very short 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.

  5. Include compilation of 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 main
    
    You'll notice there are several new flags:

  6. After getting your Makefile to work, try removing your .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!

  7. 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.