错误:'template<class T> class QList'模板参数列表中参数 1 处的类型/值不匹配
error: type/value mismatch at argument 1 in template parameter list for 'template<class T> class QList'
我正在尝试一个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 中使用此权限
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文档,它指定要使用的对象是可分配类型的,并且我已经实现了所需的函数。
感谢您提前提供的帮助:)
这意味着您已经在其他地方将Right
定义为变量、枚举常量或类似对象。例如,这里有一个重现您问题的测试用例:
class Right;
enum { Right };
QList<Right> getRights();
你可以确保你使用类如下
QList<class Right> getRights();
尽管最好使用IDE或其他东西来追踪CCD_ 2的其他定义并修复问题的根源。
相关文章:
- 如何反转整数参数包
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 如何使用默认参数等选择模板专业化
- 模板参数替换失败,并且未完成隐式转换
- 使用模板参数推导类的"outer class"
- 为什么我不能使用 std::unique_ptr 作为"模板<class>类"参数?
- 在可变参数模板化函数中同时接受 int 和 class
- SFINAE 优雅地检查"template template class"(在模板参数中)
- C :将对象引用作为参数给出错误:呼叫class :: function()的匹配函数
- 友元类不工作 C++ 、'class T'阴影模板参数的声明
- 带有“class”详细类型说明符的方法参数
- 将 BOUNDED std::参数列表<class>转换为类型 std::tuple<class,class,class> tup<classObj1, classObj
- 无法将参数 1 从 'Class *' 转换为'double []'
- 在参数中接受 2 个类的友元函数 - 未定义'Class'
- 扩展模板类的参数包<class>
- 我可以在DLL边界使用“enum class”作为函数的参数类型吗
- 错误:'template<class T> class QList'模板参数列表中参数 1 处的类型/值不匹配
- "template argument deduction for class templates"是否应该推断出可变参数类模板的空参数包?
- std::p空气作为模板<class>参数?C++
- 在c++模板中将Class作为非类型参数传递