Build the Program
To compile your assignment, use the following commands:
g++ -Wall -c Dog.cpp
g++ -Wall -c lab3.cpp
g++ -Wall Dog.o lab3.o -o lab3
The build steps for this program are a bit different than previous examples. Here is a line-by-line explanation:
- On the first line, the -c option causes Dog.cpp to be compiled but not linked. The output of this step is a file named Dog.o.
- Similarly, the second line compiles, but does not link, the program lab3.cpp and produces the file lab3.o.
- The third line links the files Dog.o and lab3.o and adds additional code needed to produce the executable program lab3. Linking is the step in which the calls to class methods in lab3.cpp are bound to actual functions in the Dog class.