2

I was wondering why i have the following compilation error.

If I remove one template it works and if i'm using the keyworkd this to access to 1_signatureBitset` it works too

#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;
    }
};

Error (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;
Chiel
  • 6,006
  • 2
  • 32
  • 57

0 Answers0