468,512 Members | 1,288 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

C++ Fraction progra using classes-Help

5
So i was given this program in class. i am supposed to create a four-function calculator for fractions using a fraction class.
Heres what the requirements are:create a member function for each of the four arithmetic operations. For example fadd(), fsub(), fmul() and fdiv(). these member functions iwll each take 1 argument(of type fraction) and return an object of type fraction. your class should provide member functions for input and output. the user should type the first fraction, an operator, and a second fraction. the program should then display the result and ask whether the user wants to continue. you should create a no argument constructor and a two argument constructor for the fraction class. your main program should have a line like:frac3 = frac1.fadd(frac2).

i was givent he formulas for the arithmetic operations. I kinda have an idea on what to do with it but the only thing im really having trouble with is the whole "these member functions will each take 1 argument (of type fraction) and return an object of type fraction" part. i dont know what the instructor means or what he wants exactly. Help would be appreciated.
Jan 17 '08 #1
1 3144
Savage
1,764 Expert 1GB
It means,that your class will have a accumulator,and that fadd,fsub..only takes one argument(of fraction type) which operates with accumulator's value,and with return type you will be able to get accumulator value and use it outside the class scope.
Jan 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by arun.hallan | last post: by
7 posts views Thread by d0ugg | last post: by
1 post views Thread by d0ugg | last post: by
2 posts views Thread by d0ugg | last post: by
17 posts views Thread by =?Utf-8?B?TWljaGVsIFBvc3NldGggW01DUF0=?= | last post: by
3 posts views Thread by Myxamatosis | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.