Note that there are some explanatory texts on larger screens.

plurals
  1. POerror: expected class-name before '{' token { ^
    text
    copied!<p>Hello I keep getting this error: expected class-name before '{' token { ^ line 15 what does this error mean exactly? Im attempting to inherit the controller class that has a function that I need to call in form1's cpp. </p> <pre><code>#ifndef FORM1_H #define FORM1_H #include &lt;QDialog&gt; #include "controller.h" namespace Ui { class form1 ; } class form1 : public QDialog, public controller { Q_OBJECT public: explicit form1(QWidget *parent = 0); ~form1(); private slots: void on_pushButton_clicked(); private: Ui::form1 *ui; }; #endif // FORM1_H </code></pre> <p>the controller class</p> <pre><code>#include "controller.h" #include "ui_controller.h" controller::controller(QWidget *parent) : QWidget(parent), ui(new Ui::controller) { ui-&gt;setupUi(this); show(1); } void controller::show(int x) { if(x==1) { myform1 = new form1(this); myform1-&gt;show(); } if(x==2) { myform2 = new form2(this); myform2-&gt;show(); } if(x==3) { myform3 = new form3(this); myform3-&gt;show(); } } controller::~controller() { delete ui; } </code></pre> <p>controller.h:</p> <pre><code>#ifndef CONTROLLER_H #define CONTROLLER_H #include &lt;QWidget&gt; #include &lt;form1.h&gt; #include &lt;form2.h&gt; #include &lt;form3.h&gt; namespace Ui { class controller; } class controller : public QWidget { Q_OBJECT public: form1 * myform1; form2 * myform2; form3 * myform3; void show(int x); explicit controller(QWidget *parent = 0); ~controller(); private: Ui::controller *ui; }; #endif // CONTROLLER_H </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload