I defined a function:
void myfunc(size_t param1, size_t param2){
...
}
it works fine. But when I try to overload this function
void myfunc(unsigned long param1, unsigned long param2){
...
}
It fails to compile with the following message: error: myfunc(unsigned long param1, unsigned long param2) cannot be overloaded.
How can I solve this problem without staic_cast the input parameters to size_t?
thanks!
It sounds like size_t and unsigned long are the same type on your system; the compiler is complaining that you have two of the same function. Furthermore, overloading with multiple number types is generally a bad idea because the compiler may not be able to recognize which overload you want due to casting possibilities. Try using templates instead:
template <T>
void myfunc(T param1, T param2){
...
}
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