0

I have a templated base class and a templated derived class. The compiler complains with

Error   C3861   'Item': identifier not found    
Error   C3861   'Max': identifier not found 

while looking at the definition of the constructor of Array.

Why can't the derived class access the base members ?

template<typename Element> class Array
{
public:
    Array() { Item = 0; Max = 0; }

    Element* Item;
    int Max;
};

template<typename Element, int Range> class StaticArray : public Array<Element>
{
public:
    StaticArray() { Item = Store; Max = Range; }

    int Store[Range];
};
  • Also: Item 43 ("Know how to access names in templatized base classes") in Effective C++, 3rd ed. – lubgr Feb 18 '19 at 10:00
  • Thanks guys, this is it. The technical explanation is arduous (as usual), but the cure is easy. –  Feb 18 '19 at 10:03

0 Answers0