Rational Fraction Call to Function

This is a discussion on Rational Fraction Call to Function within the C++ Programming forums, part of the General Programming Boards category; Hi, Hope someone can help me. I am truly new and lost. Given the code segment below, what line of ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    2

    Unhappy Rational Fraction Call to Function

    Hi,

    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!!!!!!
    Sharon
    `````````````````````````````````````````````````` ``
    Rational.h
    *************
    class Rational
    {
    public:

    Rational();

    Rational(long numerator, long denominator);

    Rational Multiply (Rational otherFrac) const;

    Rational.cpp
    **************
    Rational Rational::Multiply(Rational otherFrac)const

  2. #2
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    Code:
      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
    Posts
    2
    raimo,

    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<<endl<<endl;
    cout<<"Left fraction is ";
    left.Write(cout);
    cout<<endl<<endl;
    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
    Sharon

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, 05: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 Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM
  5. reducing a fraction
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 03-13-2002, 08:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21