Here's the deal:
When i have a function with default arguments like this one
int foo (int a, int*b, bool c = true);
If i call it by mistake like this:
foo (1, false);
The compiler will convert false to an int pointer and call the function with b pointing to 0.
I've seen people suggest the template approach to prevent implicit type conversion:
template <class T>
int foo<int> (int a, T* b, bool c = true);
But that approach is too messy and makes the code confusing.
There is the explicit keyword but it only works for constructors.
What i would like is a clean method for doing that similarly to the explicit method so that when i declare the method like this:
(keyword that locks in the types of parameters) int foo (int a, int*b, bool c = true);
and call it like this:
foo (1, false);
the compiler would give me this:
foo (1, false);
^
ERROR: Wrong type in function call (expected int* but got bool)
Is there such a method?