头文件给出错误
我正在Qt中制作一个UI,并且需要在spel.h中包含input.h,当我在mainwindow.h中使用input.h时,一切正常,但我也需要在我的spel中使用它。小时,然后QT给出了这些错误:头文件给出错误
expected ')' before '*' token Input.h R 9
ISO C++ forbids declaration of 'Form' with no type Input.h R 13
expected ';' before '*' token Input.h R13
我和我的朋友正在寻找2小时,现在仍然不明白为什么它给错误。包括卫兵一切都没问题。
Input.h:
#ifndef INPUT_H
#define INPUT_H
#include "form.h"
class Input
{
public:
Input(Form * pointer):speler(pointer){};
int geefGoederenPopup(void);
private:
Form * speler;
};
#endif // INPUT_H
是否form.h
包括input.h
?如果是这样,你有一个周期性的包含问题,这是一个包含警卫无法解决的问题。但无论如何,您可以转发声明表单而不是包含其头文件。其实我很确定这会解决问题。
没有form.h不包括input.h。并且提前宣布这个班也行不通。 – user1007522
'mainwindow.h'包含'input.h',其中包含'form.h',其中包含''mainwindow.h'。没有循环呃?除此之外,为什么在'form.h'中包含'mainwindow.h',也许你没有粘贴整个代码,或者它实际上是无用的? – azf
你说得对。这可能是问题。 – user1007522
什么是form.h?另外,请将代码放在您的实际问题中 - 而不是指向pastebin网站的链接。 – tenfour
你能告诉我们'form.h'吗?使用前向声明可能会解决您的直接问题,但我怀疑您的Form类声明存在问题。 – birryree
我的钱就在你忘记在Form类声明结尾处的分号,但在我们看到form.h文件之前,很难说。 – misha