Error: More than one instance of overloaded function matches the argument list
Error: More than one instance of overloaded function matches the argument list
我正在使用 OpenMesh 库,它们提供了两个函数 edge(),它们的区别仅在于常量。 Const edge() vs edge()。有没有办法向编译器指定我想使用哪个函数?
这似乎应该是与库不同的设计决策,但不确定我是否可以更改它,所以如果我可以做些什么来在编译器中绕过它...我正在使用 VS2013 .
我知道人们已经问过关于这个错误的问题,但我没有发现任何对这种情况有帮助的东西。
我假设你的情况是这样的:你有一个
class aclass
{
edge_t edge(void) ;
edge_t edge(void) const ;
} ;
如果您有一个 const 对象,将调用第二个版本,否则将调用非 const。所以如果你有
const aclass x ;
aclass y ;
x.edge() ; // calls the second
y.edge() ; calls the first
const_cast<const aclass &>(y).edge() ; // calls the const (second)
后者是一种(相对)安全的作弊方式...
我正在使用 OpenMesh 库,它们提供了两个函数 edge(),它们的区别仅在于常量。 Const edge() vs edge()。有没有办法向编译器指定我想使用哪个函数?
这似乎应该是与库不同的设计决策,但不确定我是否可以更改它,所以如果我可以做些什么来在编译器中绕过它...我正在使用 VS2013 .
我知道人们已经问过关于这个错误的问题,但我没有发现任何对这种情况有帮助的东西。
我假设你的情况是这样的:你有一个
class aclass
{
edge_t edge(void) ;
edge_t edge(void) const ;
} ;
如果您有一个 const 对象,将调用第二个版本,否则将调用非 const。所以如果你有
const aclass x ;
aclass y ;
x.edge() ; // calls the second
y.edge() ; calls the first
const_cast<const aclass &>(y).edge() ; // calls the const (second)
后者是一种(相对)安全的作弊方式...