【发布时间】:2020-08-03 07:15:45
【问题描述】:
我有一些模板类
template <typename T> class Base { };
我试图从 Base 继承 Derived 类,并使用嵌套在 Derived 中的 Internal 类作为Base 的通用参数。
class Derived : Base<Internal> {
public: class Internal { };
}
但编译器在 Base 中看不到 Internal。
是否可以通过将 Internal 类保持为 Derived 的嵌套来解决我的问题? 如果可能的话 - 怎么做?
【问题讨论】:
-
我担心这是否可行,但您必须使用范围:
Derived::Internal。 -
@Scheff 我也试过这个变种,结果相同,内部仍然不可见。
-
我怀疑可以使用嵌套类。前向声明也不是一种选择。也许更复杂的事情......
标签: c++ templates inheritance inner-classes