【发布时间】:2015-10-29 17:37:30
【问题描述】:
我正在尝试使用 QList 并在编译时出现错误! 这是我的代码:
class Right
{
public:
Right();
Right(const Right& other);
Right(RightName name, QDate validity_date);
bool isValid() const;
bool operator==(const Right& other)const;
Right &operator=(const Right &other);
QString name;
QDate expiryDate;
};
然后在 QList 中使用此 Right
class FileRightsRepo
{
public:
FileRightsRepo(QString rightsPath);
~FileRightsRepo() { }
// IRightsRepo interface
QList<Right> getRights();
private:
QString _rightsPath; // PATH to the file containing rights
};
我已经实现了这些类,但是当我尝试编译时,我得到了以下异常:
error: type/value mismatch at argument 1 in template parameter list for 'template<class T> class QSet'
QList<Right> getRights();
getRights() 的返回类型是什么。 我已经阅读了 Qt 文档,它指定要使用的对象是可分配的类型,并且我已经实现了所需的功能。
提前感谢您的帮助:)
【问题讨论】:
-
为什么错误是关于 QSet 的?您确定代码与错误对应吗?