【发布时间】:2014-10-26 02:31:54
【问题描述】:
以下代码
template<class T>
struct Bar
{
Bar(T& myT){}
Bar(const Bar&) = delete;
};
template<class T>
struct Foo: public T,
public Bar<T>
{
Foo(): Bar<T>(*this){}
};
class Baz{};
int main()
{
Foo<Baz> myFoo;
return 0;
}
给我这个错误:
error: call to constructor of 'Bar<Baz>' is ambiguous
我该如何解决这个问题?
(看起来很简单,我确信某处有重复,但我找不到它......我发现的所有关于“模糊构造函数”的问题都与重载的构造函数有关,这对我来说似乎不同。 )
【问题讨论】:
标签: c++ templates constructor