【发布时间】:2020-08-21 07:29:03
【问题描述】:
这是我的code:
#include <iostream>
struct Plot {
float test;
Plot() : test(1.0f) {
}
};
template <class T>
struct PlotTest : Plot {
T *pModule;
PlotTest(T *module) : Plot(), pModule(module) {
}
};
template <class T>
struct PlotTestCustom : PlotTest<T> {
PlotTestCustom(T *module) : PlotTest<T>(module) {
test = 2.0f;
}
};
int main()
{
}
但是当我编译时,PlotTestCustom 似乎看不到 float test; 变量(位于“主”父级上)。
我哪里错了?
【问题讨论】:
-
我建议将标题更改为“为什么无法在模板中访问公共基类成员?”
标签: c++ templates inheritance