can this be done somehow?
if((a || b) == 0) return 1;
return 0;
so its like...if a OR b equals zero, then...but it is not working for me.
The C++ language specifies that the operands of ||
("or") be boolean expressions.
If p1.distanceFrom(l.p1)
is not boolean (that is, if distanceFrom
returns int, or double, or some numeric class type), the compiler will attempt to convert it to boolean.
For built in numeric type, the conversion is: non-zero converts to true, zero converts to false. If the type of p1.distanceFrom(l.p1)
is of class type Foo
, the compiler will call one (and only one) user defined conversion, e.g., Foo::operator bool()
, to convert the expression's value to bool.
I think you really want something like this:
bool Circle2::contains(Line2 l) {
if((p1.distanceFrom(l.p1) <= r) || (p1.distanceFrom(l.p2) <= r)) return 1;
return 0;
}
C++ doesn't support any construct like that. Use if (a == 0 || b == 0)
.