bool Triangle::Set( double aa, double bb , double cc )
{ a=aa;
b=bb;
c=cc;
if (aa + bb <= cc || aa + cc <= bb || bb + cc <= aa)
return 1 ;
elsereturn 0 ;
}
1 2 3 4 5 6 7 8 9 10 11 12
int main()
{
int d;
Triangle r;
r.Set()=d;
If (d==1);
{
....
}
return 0;
Hi . This a just a part of my project i`m working on. and i have question. how can i return 1 or 0 from bool Triangle::Set() function example? every time i`m trying to execute this it show me an error "[Error] no matching function for call to 'Triangle::Set()'"
and "[Note] candidate expects 3 arguments, 0 provided"
thanks in advance
When you use "=" to assign it makes a difference in the order. In this case it works right to left.
To start with what you want is d = r.set(...);. next the "set" function takes three variables and you are sending nothing.
Since your are returning a "bool" from the function "d" should be defined as a "bool" not an "int" although it will work.
The if statement could be simply written as if (d) and it will work the same as what you have. Try to take advantage of what you have to work with.
Come up with better names for your variables. This is more for your benefit. Single letters and even your double single letters can be hard to follow in a larger program. Try to use a noun or sometimes a verb that describes what the variable is for or does.