Overloading member methods with typedef aliases as parameters

后端 未结 3 467
我寻月下人不归
我寻月下人不归 2021-01-19 12:49

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         


        
3条回答
  •  既然无缘
    2021-01-19 13:34

    ... they may refer to the same type in which case overloading won’t work. I want to make them work at the same time?

    Fortunately that's not possible (even with templates). Because it kills the very purpose of a typedef.
    If you intend to do this in your code then it's a code smell; you may have to change your design.

提交回复
热议问题