oRUMOo
oRUMOo

Reputation: 163

How to declare foward a template of template (of a class)

Sorry I'm new to templates and I searched a lot, but I can't find a solution how to declare forward a template of template (of a class).

Here my code:

#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

All I want is to make the #include "qvector.h" obsolent.

Upvotes: 1

Views: 711

Answers (1)

sehe
sehe

Reputation: 393019

This will do

template <typename T>  class QVector;

See on codepad:

#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

Upvotes: 8

Related Questions