Is it a bad programming principle to pass arg to a function which isn't "exact match" type wise but has trivial or user defined conversion to this type? For example:
void f(bool option);
and later in main (this is highly hypothetical so please don't give advise on that code):
int a = getSomeValue();
f(a);//here instead of bool I'm passing int - is it a bad programming practice or not?
I think most people will consider this bad practice. Writing f(a !=0)
is much clearer and expresses the intent concisely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With