'is if(s.length()) saying that if it returns a value, proceed?
Typically, I see code with say if(s.length() > 1) ..., but here it only has if(s.length()).
The length function is implemented as mentioned below. When used in the test3 function call within the file containing int main(), is if(s.length) saying that if it returns a count that is greater than zero then it will execute the body of that if statement?
int statistician::length() const
{
return count;
}
Code (test3() call in int main()):
statistician s, t, u, v;
if (s.length( ) || t.length( )) return 0; // <-- HERE
if (s.sum( ) || t.sum( )) return 0;
t.next(5);
u.next(0); u.next(10); u.next(10); u.next(20);
v = s + s;
if (v.length( ) || v.sum( )) return 0;
v = s + u;
if (!(u == v)) return 0;
v = t + s;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
