这个forward declaration有什么问题?

What is wrong with this forward declaration

本文关键字:问题 什么 forward declaration 这个      更新时间:2023-10-16

为了缩短编译时间,我多次使用了简单的习惯用法。为了得到一个"好的"头文件,我返回一个vector的指针,该指针包含QPoint的指针(一个qt对象)。

让我们看看我的头文件:

#ifndef CHEXAGON_H
#define CHEXAGON_H
class QPoint;
class QVector;
class CHexagon
{
public:
    CHexagon(const unsigned int & PosX, const unsigned int & PosY, const unsigned int & Radius);
    QVector * getEdges();
    QPoint * getCenter();
private:
    class Pimple;
    Pimple * pPimple;
};
#endif // CHEXAGON_H

怎么了?

QVector不是一个类,它是一个类模板,不能像你那样声明。

template <typename T> QVector;

,然后使用QVector<QPoint*>应该做你想要的。

无。

是什么让你觉得它有问题?