I have a template class that I am trying to inherit from another template class, but the compiler complains 'c:\Documents and Settings\rprice\My Documents\Visual Studio Projects\Terraformer3\nw.h(239): error C2542: 'array' : class object has no constructor for initialization'. The line it fails on is...
template <class T> cachedarray<T>::cachedarray(int in_size, int in_growBy):array(in_size, in_growBy)
{
// clear pointers
m_user=NULL;
}
The definition of the original class is...
template <class T> class array
{
protected:
T* m_array;
int m_arraySize;
int m_growBy;
int m_count;
public:
array() {m_arraySize=1; m_growBy=1; m_count=0; m_array=new T[m_arraySize];}
array(int in_size, int in_growBy) {m_arraySize=in_size; m_growBy=in_growBy; m_count=0; m_array=new T[m_arraySize];}
void Append(T in_element);
void RemoveAll();
// void RemoveAll() {m_count=0; return;}
int GetCount() {return m_count;}
T& operator[] (int i) {if (i > (m_count-1)) m_count=i+1; return m_array;}
};
The definition of the new class is...
template <class T> class cachedarray : public array
{
protected:
char m_resourceID[8]; // underlying API resource
Renderer* m_user; // and resource user
public:
cachedarray();
cachedarray(int in_size, int in_growBy);
~cachedarray();
void BindResourceID(Renderer* in_user, void* in_resource);
void* GetResourceID();
Renderer* GetResourceUser();
T& operator[] (int i) {if (i > (m_count-1)) m_count=i+1; return m_array;}
};
Do I have the syntax wrong? I thought I could just pass to the base class constructor even though it's a template. Can I not do this?
Thanks!