zoukankan      html  css  js  c++  java
  • error: must use ‘class’ tag to refer to type ‘XXX’ in this scope

    开发环境: Qt Creator 4.11.0
    在写程序的时候,遇到了编译器报错 error: must use 'class' tag to refer to type 'thread' in this scope

    void Server::incomingConnection(int socketDescriptor)
    {
        thread *h = new   thread(socketDescriptor);
        connect(h,&thread::isFinished,h,&thread::deleteLater);//当线程完成后,释放内存
        h->start();
    }
    

      thread是我定义的一个类(线程),查找原因发现,thread是QObject类的一个函数,所以需要指明是是一个类。

    QThread *QObject::thread() const

    修改如下:

    void Server::incomingConnection(int socketDescriptor)
    {
        class thread *h = new  class thread(socketDescriptor);
        connect(h,&thread::isFinished,h,&thread::deleteLater);//当线程完成后,释放内存
        h->start();
    }
    

      

    懒惰不会让你一下子跌到 但会在不知不觉中减少你的收获; 勤奋也不会让你一夜成功 但会在不知不觉中积累你的成果 越努力,越幸运。
  • 相关阅读:
    67家基金子公司背景脉络梳理
    港股奇葩术语知多少
    68家信托公司7大派系股东分食图谱
    港股术语
    流动性陷阱
    ORACLE归档模式和非归档模式的利与弊
    肥尾效应
    DVP
    金融衍生品如何定价
    绿鞋机制
  • 原文地址:https://www.cnblogs.com/Rainingday/p/12715069.html
Copyright © 2011-2022 走看看