Discussion:
A4Q2 - file contents
(too old to reply)
Daniel Crookston
2011-06-29 00:54:01 UTC
Permalink
I'm a bit confused about what is supposed to be in the files q2driver.cc
and q2rationalnumber.h.

I assume that q2rationalnumber.h should contain our implementation of
rationalnumber. Are we supposed to have another header file that
contains the q2code that was given?

Some help in this area would be appreciated.

-Daniel
Jeremy Roman
2011-06-29 11:37:14 UTC
Permalink
Post by Daniel Crookston
I'm a bit confused about what is supposed to be in the files q2driver.cc
and q2rationalnumber.h.
I assume that q2rationalnumber.h should contain our implementation of
rationalnumber. Are we supposed to have another header file that
contains the q2code that was given?
Some help in this area would be appreciated.
-Daniel
If you haven't already, I would suggest taking another look at section
2.23 ("Separate Compilation") of the course notes. It says that
"Interface is entered into one or more include files (.h files), and the
implementation is entered into one or more source files (.cc files)."

Following that guideline, q2rationalnumber.h should describe the
*interface* of the Rationalnumber class, and q2rationalnumber.cc should
contain the implementation.

The course notes contain more detail about how to separate them like this.
--
Jeremy Roman
Student, Computer Science
University of Waterloo
acchow
2011-06-30 19:01:59 UTC
Permalink
Post by Jeremy Roman
Post by Daniel Crookston
I'm a bit confused about what is supposed to be in the files q2driver.cc
and q2rationalnumber.h.
I assume that q2rationalnumber.h should contain our implementation of
rationalnumber. Are we supposed to have another header file that
contains the q2code that was given?
Some help in this area would be appreciated.
-Daniel
If you haven't already, I would suggest taking another look at section
2.23 ("Separate Compilation") of the course notes. It says that
"Interface is entered into one or more include files (.h files), and the
implementation is entered into one or more source files (.cc files)."
Following that guideline, q2rationalnumber.h should describe the
*interface* of the Rationalnumber class, and q2rationalnumber.cc should
contain the implementation.
The course notes contain more detail about how to separate them like this.
Which file should contain the global statistics? Inuitively, it seems
that Rationalnumber.cc should contain the global statistics (that way
the statistics have fixed names and the methods can increment them
accordingly).

But then, how will I be able to make the statistics consistent across
implementation? I can think of two implementations of the relation
operators that will produce different statistics. In one, when calling "
<= " the routine returns boolean directly. In another implementation, I
make " <= " recursively call " < " when necessary. So which is it?
Jeremy Roman
2011-06-30 19:35:00 UTC
Permalink
Post by acchow
Which file should contain the global statistics? Inuitively, it seems
that Rationalnumber.cc should contain the global statistics (that way
the statistics have fixed names and the methods can increment them
accordingly).
But then, how will I be able to make the statistics consistent across
implementation? I can think of two implementations of the relation
operators that will produce different statistics. In one, when calling "
<= " the routine returns boolean directly. In another implementation, I
make " <= " recursively call " < " when necessary. So which is it?
Hmmm...I know how I've written my program, but this is straying close
enough to assignment territory that I'll defer that to course staff. :)
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Ashif Harji
2011-06-30 20:51:46 UTC
Permalink
Which file should contain the global statistics? Inuitively, it seems that
Rationalnumber.cc should contain the global statistics (that way the
statistics have fixed names and the methods can increment them accordingly).
But then, how will I be able to make the statistics consistent across
implementation? I can think of two implementations of the relation operators
that will produce different statistics. In one, when calling " <= " the
routine returns boolean directly. In another implementation, I make " <= "
recursively call " < " when necessary. So which is it?
These are implementation details that you will have to figure out on your
own. Please do not discuss implementation specifics on the newsgroup. If
you are stuck, then see one of the course staff.

ashif

Loading...