So I've created this class which can add the two values of two objects. What I don't really understand is in the operator function, does the values of numerator and denominator come from the object no1 in int main()?
class frac
{
public:
frac operator+(frac&);
frac();
frac(int, int);
int numerator;
int denominator;
};
frac frac::operator+(frac& tmp)
{
frac tmpResult;
tmpResult.numerator = numerator + tmp.numerator;
tmpResult.denominator = denominator + tmp.denominator;
return tmpResult;
}
int main()
{
frac no1(2, 5);
frac no2(3, 6);
frac result = no1 + no2;
return 0;
}