Hi everyone,
I know this problem has been encountered thousands of times before, so I checked everywhere on the net but I still did not manage to solve this problem this time.
It is apparently due to a confusion with the initialization of the class and a function.
Here is the interesting part of the code:
A function in main.cpp
1 2 3 4 5 6 7 8 9 10 11 12
Frac demanderfrac(Frac eg)
{
int num;
int denom;
cout << "Enter number 1: ";
cin >> num;
cout << endl;
cout << "Number 2 now: ";
cin >> denom;
cout << endl;
return eg(num, denom); //Here is the error: no match for call to '(Frac) (int&, int&)'
}
Your problem is contained in the following snippet:
1 2 3 4
Frac demanderfrac(Frac eg)
{
return eg(num, denom); //Here is the error: no match for call to '(Frac) (int&, int&)'
}
First eg is a variable, an instance of your Frac class that you passed into this function as a parameter. If you want to return this variable then you would just use: return eg;
You would then need to use a public function in your class to alter the private variables of your class.
If you want to return a different Frac then you could do something like: return Frac(num, denom);
But then you wouldn't need to pass eg into this function.
Thank you so much fg109 I did like your first suggestion and it worked perfectly, the only thing is that I wouldn't be able to do it by myself, but I understood how it worked.
So the only thing I want to tell you all now is thank you ;)