相关疑难解决方法(0)

使用typedef别名作为参数重载成员方法

我在使用C++重载方法时遇到了一些麻烦.

typedef char int8_t;
class SomeClass{
public:
…
void Method(int8_t paramater);
void Method(char paramater);
};
Run Code Online (Sandbox Code Playgroud)

因为int8_ttypedef char只是别名,所以它们可能引用相同的类型,在这种情况下,重载将不起作用.

我想让它们同时工作?你能建议解决方案吗?注意:我不想添加模板化方法.

以下是错误:

错误:SomeClass :: Method(char)的多个声明

c++ overloading compiler-errors

4
推荐指数
2
解决办法
2689
查看次数

标签 统计

c++ ×1

compiler-errors ×1

overloading ×1