dra*_*oot 8 c++ inheritance using language-lawyer
以下内容由 gcc(12.1 和 trunk)编译良好,但 clang(14.0.0 和 trunk)在 上给出错误d.foo(),表示调用不明确。问题是,我应该向哪个编译器报告错误?
class Base
{
public:
void foo() {}
};
class Derived: public Base
{
public:
using Base::foo;
void foo() & {}
};
int main()
{
Derived d;
// Clang says here: error: call to member function 'foo' is ambiguous. Gcc,
// however, is fine with it
d.foo();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |