如何声明模板模板(类)

oRU*_*MOo 0 c++ templates forward-declaration

对不起,我是模板的新手,我搜索了很多,但我找不到解决方法如何声明转发模板(类的).

这是我的代码:

#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
Run Code Online (Sandbox Code Playgroud)

我想要的只是让#include"qvector.h"过时了.

seh*_*ehe 7

这样做

template <typename T>  class QVector;
Run Code Online (Sandbox Code Playgroud)

在键盘上看到:

#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
Run Code Online (Sandbox Code Playgroud)