简体   繁体   中英

Header file gives error

I'm making a UI in Qt and need to have input.h included in spel.h, when I use input.h in my mainwindow.h everything works but I also need him in my spel.h and then QT gives these errors:

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   

Me and my friend are searching for 2 hours right now and still don't see why it's giving errors. Include guards everything is okay.

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

Does form.h include input.h ? If so, you have a cyclic include problem that can't be solved with an include guard. But in any case, you can forward declare Form instead of including its header file. Actually I'm pretty sure that will solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM