I’m having some trouble overloading methods in C++.
typedef char int8_t;
class SomeClass{
public:
…
void Method(int8_t paramater);
void Method(char paramater);
};
Since int8_t
is typedef as char
they are just aliases, they may refer to the same type in which case overloading won’t work.
I want to make them work at the same time? Can you suggest solution to the same. Note: I do not want to add templated method.
Following is the error:
Error: Multiple declaration for SomeClass::Method(char)
Use a faux type. Wrap one of char
or int8_t
in a structure and use the structure as a parameter.
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