Hi, I added the following functionality to my project but get an error message a
ID: 3648044 • Letter: H
Question
Hi,I added the following functionality to my project but get an error message as follows (code is below) Thanks
Error 1 One of the parameters of a binary operator must be the containing type c:usersocdobbsdocumentsisual studio 2010ProjectsConsoleApplication7ConsoleApplication7Program.cs 141 28 ConsoleApplication7
public static Fraction operator*(Fraction frac1, Fraction frac2)
{
int firstProduct1 = (frac1.WholeNumber * frac1.Numerator) + frac1.Numerator;
int secondProduct2 = (frac2.WholeNumber * frac2.Denominator) + frac2.Numerator;
int iNumerator=firstProduct1*secondProduct2;
int iDenominator = frac1.Denominator * frac2.Denominator;
return ( new Fraction(iNumerator,iDenominator));
}
Explanation / Answer
the error is in your method signature.. public static Fraction operator*(Fraction frac1, Fraction frac2) remove * between operator and paranthesis .. it will be solved :)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.