-
September 25th, 2013, 12:35 PM
#1
Class fraction - overloading operators
the question am having problems with..
1.Write a class function that defines adding, subtracting, multiplying and dividing fractions by overloading standard operators for the operations.
2. Write a function member for reducing factors and overload I/O operators to input and output fractions.
how would i set this up anyone? thanks am really late on it, got tons of other homework and its due today..
-
September 25th, 2013, 12:51 PM
#2
Re: Class fraction - overloading operators
Originally Posted by KANGALIO
how would i set this up anyone?
Programming isn't like other school subjects, where you can "cram" things in one day. You need to show what you've done.
In addition, the answer to each of your questions is that it takes days, if not weeks of work, to plan and implement each of those items. Unless you're a C++ expert (or close to it), and have no other commitments, there is no way both items can be done in one day or less.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; September 26th, 2013 at 12:27 AM.
-
September 25th, 2013, 10:50 PM
#3
Re: Class fraction - overloading operators
got tons of other homework and its due today..
Noone here will "do" your homework for you. With that in mind Ive written the library you are talking about, it took about a few weeks to get most of what youre asking for up and running but I also implemented implicit conversions from all the built in types as well as explicit conversions to all the built in types. Anyways, the library you were asked to build is straight forward and fairly easy, if I wasnt working full time when I built it, I probably could have had it up and running in less than a week.
-
September 26th, 2013, 08:32 AM
#4
Re: Class fraction - overloading operators
hmm really ? weeks ?
1) is doable in an hour or 2 if you're fairly new to C++.
it's a typical/classic type task much like designing a class to handle complex numbers.
2a) reducing factors is 'tricky'. the principle is simple enough, but I would assume you either have been given the methodology to do this (and just need to codify this method in C++) or you have done previous tasks that do part of the work of this
as to method.
If this is a pure C++ class, then I'd expect your teacher to have explained/told you what is expected or this was part of the assignment description. in that case, writing this function should equally take an hour or so.
if it's a mixed 'applied C++ to math' type class, then the methodololy may be part of the assignment so you'll have to figure this one out. it may take you a bit longer to figure out the right method for this first.
2b) input and output operators... Depends how you want them, but it shouldn't be that hard to write either.
I'm not sure why you guys say "weeks". I can do the whole thing in an hour or so. I would expect a novice to manage this task in (much) less than a day.
maybe if you added lots of overrides for all kinds of types... "maybe", but this isn't the assignment here, it's just fractions operating on other fractions, reducing and basic input/output.
-
September 26th, 2013, 09:56 AM
#5
Re: Class fraction - overloading operators
I would expect a novice to manage this task in (much) less than a day.
Well, your expectations are high.
The average student taking C++, and especially if it's their first language, could not complete this assignment in less than a day -- believe me, I have taught C++. In the best case scenario for a good student (everything has been described to them, taught, sample programs provided, etc.). maybe a day.
Regards,
Paul McKenzie
-
September 27th, 2013, 06:40 AM
#6
Re: Class fraction - overloading operators
Originally Posted by Paul McKenzie
The average student taking C++, and especially if it's their first language, could not complete this assignment in less than a day -- believe me, I have taught C++. In the best case scenario for a good student (everything has been described to them, taught, sample programs provided, etc.). maybe a day.
I'll agree it depends on how much they've been at it. But this type of task isn't the kind of thing you'd give someone in the first few days. If it's that early on, I would have expected the assignment description to be much more detailed. Or rather, I would have expected a considerably simpler assignment.
I was sort of assuming that they had worked through the first few chapters of a course on C++ and had already done several other programs and thus be familiar with stuff like operator overloading and the c++ input/output system/streams.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|