...
Code Block | ||||
---|---|---|---|---|
| ||||
void set_flag(int number, int *sign_flag) { if (sign_flag == NULLnullptr) { return; } if (number > 0) { *sign_flag = 1; } else if (number < 0) { *sign_flag = -1; } } void func(int number) { int sign; set_flag(number, &sign); /* use sign */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
void set_flag(int number, int *sign_flag) { if (sign_flag == NULLnullptr) { return; } if (number >= 0) { /* account for number being 0 */ *sign_flag = 1; } else { assert(number < 0); *sign_flag = -1; } } void func(int number) { int sign; set_flag(number, &sign); /* use sign */ } |
...