C++ error: Invalid use of incomplete type …

后端 未结 3 1663
余生分开走
余生分开走 2021-01-05 05:26

I have a small- to medium-size project that I am doing for my software engineering course this semester. I have chosen to do it in C++ (gtkmm). I am doing okay so far but I

3条回答
  •  心在旅途
    2021-01-05 06:07

    You can get away with forward declaring MainWindow in Login_Dialog.h as long as you only forward declar a pointer to the type (which you do), and you add this to the top of Login_Dialog.h so the compiler knows to expect to see a class declaration at some later time.

    class MainWindow;
    

    Then in Login_Dialog.cpp, include "mainwindow.h" like this.

    /*
     * Login_Dialog.cpp
     *
     *  Created on: Mar 2, 2010
     *      Author: Matthew
     */
    
    #include "Login_Dialog.h"
    #include "MainWindow.h"
    

    That should do it.

提交回复
热议问题