und*_*ind 5 c++ inheritance templates template-argument-deduction
以下代码片段仅在我T为ctor 中的Base结构明确指定模板参数时才编译Derived:
template <class T>
struct Base
{
Base(int) {}
};
template <class T>
struct Derived : Base<T>
{
Derived(int i) : Base<T>(i) {}
};
Run Code Online (Sandbox Code Playgroud)
如果我调用Base(i)而不是Base<T>(i)- 它不起作用。为什么编译器不能确定它Base实际上是Base<T>(因为我来自Base<T>)?这个要求是故意的吗?
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |