mixing unsigned and signed
One thing that always annoyed me about C and C++ is that sometimes you are forced to mix unsigned and signed types. For instance when you pass an array to a function and to be correct you better pass a size_t as the size too.
Code:
void func(OBJ results[3], size_t n) {
for (int i = 0; i < n; i++) {
if (results[i] != 0)
results[i].SetVal(i);
}
}
}
Then if you loop through the array with an int you get the warning that you're mixing unsigned and signed types but if you change it to size_t and the SetVal expects an int then you get the warning there.
How do you guys solve this?