Discussion:
A4Q2 - reference .o files
(too old to reply)
THOM BOHK
2011-06-28 05:14:04 UTC
Permalink
I'm having trouble understanding how to use the reference .o files
provided for q2...

I would guess from page 126 of the notes that I am to go

g++ q2driver.cc rationalnumber_64.o

in order to test your implementation on my driver to see how well it
matches my own implementation being run on my driver.

I get errors from executing that command, though, which seem to stem
from the fact that my driver has an #include "q2rationalnumber.h" that
isn't able to include, which I would guess is from a problem with
the .o file? Or I'm not understanding how to use the .o ...
Jeremy Roman
2011-06-28 12:52:56 UTC
Permalink
Post by THOM BOHK
I'm having trouble understanding how to use the reference .o files
provided for q2...
I would guess from page 126 of the notes that I am to go
g++ q2driver.cc rationalnumber_64.o
in order to test your implementation on my driver to see how well it
matches my own implementation being run on my driver.
I get errors from executing that command, though, which seem to stem
from the fact that my driver has an #include "q2rationalnumber.h" that
isn't able to include, which I would guess is from a problem with
the .o file? Or I'm not understanding how to use the .o ...
You should still have a header file, q2rationalnumber.h, which more or
less describes the interface of the Rationalnumber class, so that your
q2driver.cc file knows what a Rationalnumber looks like. If you include
this header in q2driver.cc but it does not exist, then q2driver.cc will
not compile (regardless of which rationalnumber.o implementation you are
trying to use).

The .o file is only used in the next step afterwards (linking). If your
q2driver.cc file compiles, this will succeed as long as the interface
you describe in your header file matches the one implemented by the
provided object file. This is why you cannot change the type signatures
of the public methods: they would break this compatibility.
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Continue reading on narkive:
Loading...