Как объявить шаблон шаблона (класса) - PullRequest
0 голосов
/ 23 апреля 2011

Извините, я новичок в шаблонах и много искал, но не могу найти решение, как объявить пересылку шаблона (класса).

Вот мой код:

#ifndef CMAP_H
#define CMAP_H

#include "qvector.h"

class CMap
{
public:
    CMap(const unsigned int & width, const unsigned int & height, const unsigned int & hexagonRadius);
    CMap(const unsigned int & width, const unsigned int & height, const unsigned int & hexagonRadius, const QVector<QVector<unsigned int> > & landType);
    ~CMap();
private:
    class Pimple;
    Pimple * d;
};

#endif // CMAP_H

Все, что я хочу, это сделать #include "qvector.h" устаревшим.

1 Ответ

7 голосов
/ 23 апреля 2011

Это будет делать

template <typename T>  class QVector;

См. на кодовой панели :

#ifndef CMAP_H
#define CMAP_H

template <typename T>  class QVector;

class CMap
{
public:
    CMap(const unsigned int & width, const unsigned int & height, const unsigned int & hexagonRadius);
    CMap(const unsigned int & width, const unsigned int & height, const unsigned int & hexagonRadius, const QVector<QVector<unsigned int> > & landType);
    ~CMap();
private:
    class Pimple;
    Pimple * d;
};

#endif // CMAP_H
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...