【发布时间】:2016-11-14 16:08:52
【问题描述】:
今天遇到一个很奇怪的问题,就是我的IDE总是不能识别我最后包含的最后一个类。我用的是Qt Creator,我的包含如下:
#include "realtimemonitor.h"
#include "ui_realtimemonitor.h"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QHBoxLayout>
#include "forkliftinfo.h"
#include <thread>
#include "goodsitem.h"
#include "goodslocationitem.h"
#include "forkliftitem.h"
#include "chargingstationitem.h"
此时,IDE 报错“ChargingStationItem 未声明的标识符”。 如果我将 forkliftitem.h 与 chargingstationitem.h 交换,IDE 将包含“ForkliftItem 未声明的标识符”。我的 forkliftitem.h强>如下:
//forkliftitem.h
#ifndef CHARGINGSTATIONITEM_H
#define CHARGINGSTATIONITEM_H
#include <QGraphicsItem>
class ForkliftItem : public QGraphicsItem { public:
ForkliftItem();
};
#endif // CHARGINGSTATIONITEM_H
还有chargestationitem.h:
//chargingstationitem.h
#ifndef CHARGINGSTATIONITEM_H
#define CHARGINGSTATIONITEM_H
#include <QGraphicsItem>
class ChargingStationItem : public QGraphicsItem { public:
ChargingStationItem();
};
#endif // CHARGINGSTATIONITEM_H
【问题讨论】:
-
由 Crawl.W 于 2016 年 11 月 14 日 16:08 提出这不是一个无意义的问题,只是不太常见。无论是粗心还是编辑器错误,这个问题在这些时候都会有所帮助。采纳的答案是投票的 3 倍,足以表明他的贡献。