Thread: Rational Fraction Call to Function

  1. #1
    Registered User
    Join Date
    Jun 2002

    Unhappy Rational Fraction Call to Function


    Hope someone can help me. I am truly new and lost.

    Given the code segment below, what line of code would I use to call for Rational Rational::Multiply(Rational otherFrac)const in the main tester program?

    Thank you!!!!!!
    `````````````````````````````````````````````````` ``
    class Rational


    Rational(long numerator, long denominator);

    Rational Multiply (Rational otherFrac) const;

    Rational Rational::Multiply(Rational otherFrac)const

  2. #2
    Registered User raimo's Avatar
    Join Date
    Jun 2002
      Rational r(2,0), p(2,5); //Two instances
      Rational q = r.Multiply(p); // declare new instance of the class 
      // with the return value from Multiply method

  3. #3
    Registered User
    Join Date
    Jun 2002

    Thanks for your lightning quick response

    What do the p & r stand for. Are they new variables that I need to declare? Here is a little more of my code

    int main()
    char operationRequest;// this is just a portion of the code
    Rational left, right(3, 4), result;

    case '*':

    cout <<"Please enter fraction in N/D form"<< endl;
    left.Read (cin);
    cout<<"Left fraction is ";
    Rational Multiply(Rational otherFrac);

    // I thought I could call for the function object like the above but it doesn't work even though I don't get any errors. I have a print command [before any other code] under,

    Rational Rational::Multiply(Rational otherFrac)const

    just to check the flow and it doesn't print.

    Hope this isn't too confusing, please help if you can. I'm going to look over your code and see if I can decipher it.

    Thank you so much for responding

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with Rational Numbers (C++)
    By cloudjc in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2008, 04:03 PM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. reducing a fraction
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 03-13-2002, 08:56 PM