Here is a bit of the code in question. the error is in line 13, "x = c.addition(d);" the problem has to do with something in another part of the code, as this section is a driver program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
int main()
{
Rational c( 2, 6 );
Rational d( 7, 8 );
Rational x; // creates three rational objects
c.reduction();
d.reduction();
c.printRational(); // prints rational object c
cout << " + ";
d.printRational(); // prints rational object d
x = c.addition( d ); // adds object c and d; sets the value to x
x.reduction();
cout << " = ";
x.printRational(); // prints rational object x
...
system("pause");
return 0;
| |
The program has a header file, which is simply the class definition. It is correct.
Thus, the problem (insofar as I can determine) must lie in the addition function, shown below.
1 2 3 4 5 6 7 8 9
|
void Rational::addition(Rational d) // adds fractions
{
int numerSum;
numerSum = (numerator * d.getDenominator()) + (denominator * d.getNumerator());
if (denominator <= d.getDenominator())
{
denominator = d.getDenominator();
}
}
| |
I very well could be off base with this, so I am open to criticism. I have been programing for 4 years now, 2 of which at the collegiate level. Thus, I know the concepts fairly well, but some of the grittier applications throw me, and compiler error wording is, to say the least confusing, and, not far from that, a foreign language to me.
As a side note, I am using the DEV C++ compiler.
My friends are busy and my instructor is out of the office, so I need some help from those at this site. Thank you for any help or insight you can offer.