The member element of a C ++ template template in a template class has an incomplete type

I have code similar to the following in the header file:

template<class A>
class List {
  private:
    QVector<A> _list;
};

where QVector is the standard QT container.

When I try to make a variable of type List as a member variable in another header file, for example:

class Model {
  private:
    List<int *> the_list;
};

I get the following error:

In instantiation of 'List<int *>':
instantiated from here
error: 'List<A>::_list' has incomplete type

Basically, I want a template template that uses an internal QVector to store data items.

I assume my syntax is not working a bit, so any help would be appreciated.

+3
source share
1 answer

class List { } , #include d QVector. , QVector - undefined, List , List .

#include <QVector>

template<class A>
class List {
  private:
    QVector<A> _list;
};
+5

Source: https://habr.com/ru/post/1761646/


All Articles