我想知道为什么我有以下编译错误。
如果我删除一个模板就可以了 如果我使用keyworkd这访问1_signatureBitset`它也有效
#include <iostream>
template<typename T>
class BaseSystem {
public:
explicit BaseSystem(const int &signatureBitset) noexcept
: _signatureBitset(signatureBitset) {}
virtual void update() = 0;
public:
const int _signatureBitset;
};
template<typename T>
class HealthSystem : public BaseSystem<T> {
public:
explicit HealthSystem(const int &signatureBitset)
: BaseSystem<T>(signatureBitset) {}
void update() override {
std::cout << _signatureBitset << std::endl;
}
};
错误(g ++ 7.2.1):
test.cpp: In member function ‘void HealthSystem<T>::update()’:
test.cpp:22:20: error: ‘_signatureBitset’ was not declared in this scope
std::cout << _signatureBitset << std::endl;