Discussion:
A4Q2 constructors without parameters
(too old to reply)
Rachel
2011-06-30 22:31:35 UTC
Permalink
Hi.
I noticed for A4 Question 2 that we have to write a couple of
constructors for Rationalnumber that are not passed the full list
parameters. I.e. they're missing one or both of num and denom. Can
we just initialize the missing values to be whatever we want them to
be then? For example, just initialize the Rationalnumber to 0 if no
num or denom exist? Thanks.
Ashif Harji
2011-06-30 23:08:36 UTC
Permalink
A number of things are not fully specified in the assignment
specification. However, these types of questions can be answered by
building an executable with the provided reference .o file and q2driver.cc
with appropriate commands. The following command may be helpful:

g++ q2driver.cc rationalnumber_64.o

Let me know if you are having trouble building the executable.

ashif
Post by Rachel
Hi.
I noticed for A4 Question 2 that we have to write a couple of
constructors for Rationalnumber that are not passed the full list
parameters. I.e. they're missing one or both of num and denom. Can
we just initialize the missing values to be whatever we want them to
be then? For example, just initialize the Rationalnumber to 0 if no
num or denom exist? Thanks.
Dustin Fader
2011-07-05 00:39:27 UTC
Permalink
Post by Ashif Harji
A number of things are not fully specified in the assignment
specification. However, these types of questions can be answered by
building an executable with the provided reference .o file and
q2driver.cc with appropriate commands. The following command may be
g++ q2driver.cc rationalnumber_64.o
Let me know if you are having trouble building the executable.
ashif
Post by Rachel
Hi.
I noticed for A4 Question 2 that we have to write a couple of
constructors for Rationalnumber that are not passed the full list
parameters. I.e. they're missing one or both of num and denom. Can
we just initialize the missing values to be whatever we want them to
be then? For example, just initialize the Rationalnumber to 0 if no
num or denom exist? Thanks.
I'm a little confused about the behaviour of Rationalnumbers being
created with no parameters. Specifically how certain functions ( <, >,
etc.) are producing compilation errors when attempted on these objects.

My code behaves the same as the executable, but I'm a little curious as
to why the object is no longer being treated as a Rationalnumber. Is
this the correct behaviour, and can we assume that you won't test these
functions that produce the errors?

Loading...