### Where should i put my bool function?

Where should i include my bool isSolvable function so that it will be no error.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354`` ``````#include #include #include using namespace std; void solveEquation(double,double,double,double,double,double,double &,double &, bool &); bool isSolvable(double a, double b,double c,double d) { if ((a*d)-(b*c) == 0) {return true;} else return true; } void solveEquation(double a, double b, double c, double d, double e, double f, double &x, double &y, bool &isSolvable) { x = (e*d - b* f)/(a*d - b*c); y = (a*f - e* c)/(a*d-b*c); } int main () { double a; double b; double c; double d; double e; double f; double x; double y; double g; bool isSolvable; cout << "Enter a, b, c, d, e, f: "; cin >> a; cin>> b; cin >> c; cin >> d; cin >> e; cin >> f; solveEquation(a,b,c,d,e,f,x,y, isSolvable); cout << fixed << setprecision(1) << "x is " << x << " and y is " << y << endl; } ``````
a) Your function is bogus. Whatever happens, the result is "true". Most likely, the first "return true" should be "return false".

b) You're not calling your function. You're declaring a new bool variable with the same name, which is always a bad idea. Additionally, you're not initializing it.

c) There is no point for isSolvable (the argument in solveEquation) to be a reference. You can immediately pass the result of isSolvable (the function) to solveEquation by calling it this way:
`solveEquation(a,b,c,d,e,f,x,y, isSolvable(a, b, c, d));`
That can't be done as a reference (or at least shouldn't be).

Alternatively, you can first solve the result (in a bool variable with a differfent name, preferably) and then pass the variable:
` bool isTotallySolvable = isSolvable(a, b, c, d);` `solveEquation(a,b,c,d,e,f,x,y, isTotallySolvable);`
Now you can keep the parameter as a reference (still completely useless though).
http://imageshack.us/a/img341/555/questionx.jpg

the question asked me to make it a reference.
Then save the result in a variable, then pass the variable to the function.
The question did not tell you to make a function named isSolvable.
i know. but i dont know where and how should i define the bool inside the void.
On line 34 you are declaring a variable whose name is allready "reserved" :)
(ambigous simbol error)
function is called by typing it's name followed by brackets and arguments(if any).

Also I suppose your last argument in solveEquation function must not be a reference to local variable?

In case you don't understand local variables and function parameters I would recomment you to read Chapter 7 section 2 of Stroustrup's book which can be located here:
 http://www.stroustrup.com/3rd.html
Topic archived. No new replies allowed.