我有一个对话框窗口settings
,我想显示我的breadData
对象的所有值,为此我希望拥有settings
inheritbreadData
的受保护成员。我尝试转发声明 breadData,但我的代码中出现了几个错误。
/home/--/breadPull/prj/settings.h:14: error: invalid use of incomplete type 'struct breadData'
/home/--/breadPull/prj/resultwnd.h:7: error: forward declaration of 'struct breadData'
一方面,breadData
不是结构,为什么编译器认为 breadData 是结构?其次,我不明白第二行想说什么。我唯一的猜测是因为我的程序中有很多循环依赖。以下是相关代码:
设置.h
#include <QDialog>
#include "breaddata.h"
class breadData;
namespace Ui {
class Settings;
}
class Settings : public QDialog, public breadData
{
Q_OBJECT
//.....
面包数据.h
#include <vector>
#include <string>
#include <QtWidgets>
#include <QMainWindow>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "resultwnd.h"
#include "settings.h"
class MainWindow;
class resultWnd;
class breadData
{
public:
breadData(std::string);
~breadData();
//read in data file that provides all information
bool readData();
//.......
结果Wnd.h
include <QGroupBox>
#include "breaddata.h"
class breadData;
namespace Ui {
class resultWnd;
}
class resultWnd : public QGroupBox
//.....