SPHERE
The object file sphere.o must be recreated because function definitions in sphere.cxx have changed. In addition, we can also create a ball.o object file with the following commands at the prompt:
>CC -c sphere.cxx >CC -c ball.cxx
This compiles the programs sphere.cxx
and ball.cxx into the
objects sphere.o and ball.o.
The main.cxx file can
be compiled and linked with the following command at the prompt:
>CC -o sphere main.cxx sphere.o ball.o
The inclusion of sphere.o and ball.o at the end of the compilation command indicates that the object should be linked with the main.o object when linking to form the executable sphere.
The execution of the program remains the same:
>sphere
mySphere has radius: 10.0
myOtherSphere has radius: 10.0
myOtherSphere has X position: 3.0
myBall has position X: 3.0 Y: 4.0 Z: 10.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
myBall has position X: 3.2 Y: 4.0 Z: 11.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
myBall has position X: 3.4 Y: 4.0 Z: 12.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
myBall has position X: 3.6 Y: 4.0 Z: 13.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
...
myBall has position X: 31.8 Y: 4.0 Z: 99.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
myBall has position X: 32.0 Y: 4.0 Z: 100.0
myBall has velocity X: 0.2 Y: 0.0 Z: -1.0
myBall has position X: 32.2 Y: 4.0 Z: 99.0
myBall has velocity X: 0.2 Y: 0.0 Z: -1.0
myBall has position X: 32.4 Y: 4.0 Z: 98.0
myBall has velocity X: 0.2 Y: 0.0 Z: -1.0
...
myBall has position X: 49.6 Y: 4.0 Z: 2.0
myBall has velocity X: 0.2 Y: 0.0 Z: -1.0
myBall has position X: 49.8 Y: 4.0 Z: 1.0
myBall has velocity X: 0.2 Y: 0.0 Z: -1.0
myBall has position X: 50.0 Y: 4.0 Z: 0.0
myBall has velocity X: 0.0 Y: 0.0 Z: 0.0
myBall has position X: 3.0 Y: 4.0 Z: 10.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0
myBall has position X: 3.2 Y: 4.0 Z: 11.0
myBall has velocity X: 0.2 Y: 0.0 Z: 1.0