Note that there are some explanatory texts on larger screens.

plurals
  1. POInheritance Error
    primarykey
    data
    text
    <p>I made the following program, but now i am getting an error. I searched for error almost 3 hours but worthless. I want to discuss the problem with you people. I am getting the error: expected class-name before '{' token</p> <pre><code>#ifndef ASKDIALOG_H #define ASKDIALOG_H #include &lt;QDialog&gt; #include "umerwindow.h" namespace Ui { class AskDialog; } class AskDialog : public QDialog, public UmerWindow // HERE IS THE ERROR { Q_OBJECT public: explicit AskDialog(QWidget *parent = 0); void showdialog(); ~AskDialog(); private slots: void on_dokbutton_clicked(); private: Ui::AskDialog *ui; }; #endif // ASKDIALOG_H </code></pre> <p>ASK DIALOG .CPP FILE</p> <pre><code>#include "askdialog.h" #include "ui_askdialog.h" AskDialog::AskDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AskDialog) { ui-&gt;setupUi(this); } AskDialog::~AskDialog() { delete ui; } void AskDialog::on_dokbutton_clicked() { QString data=ui-&gt;dline-&gt;text(); showlist(data); } </code></pre> <p>ASK DIALOG .CPP FILE</p> <pre><code>#include "askdialog.h" #include "ui_askdialog.h" AskDialog::AskDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AskDialog) { ui-&gt;setupUi(this); } AskDialog::~AskDialog() { delete ui; } void AskDialog::on_dokbutton_clicked() { QString data=ui-&gt;dline-&gt;text(); showlist(data); } </code></pre> <p>Ok so this the header file of UmerWindow</p> <pre><code>#ifndef UMERWINDOW_H #define UMERWINDOW_H #include &lt;QMainWindow&gt; #include &lt;QListWidgetItem&gt; #include "askdialog.h" namespace Ui { class UmerWindow; } class UmerWindow : public QMainWindow { Q_OBJECT public: explicit UmerWindow(QWidget *parent = 0); ~UmerWindow(); protected: void showlist(QString &amp;); private slots: void on_actionAdd_Item_triggered(); private: Ui::UmerWindow *ui; QListWidgetItem *itm; AskDialog *dialog; }; </code></pre> <p>and this is the .cpp file of UmerWIndow</p> <pre><code>#include "umerwindow.h" #include "ui_umerwindow.h" #include "askdialog.h" #include &lt;QListWidgetItem&gt; UmerWindow::UmerWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::UmerWindow) { ui-&gt;setupUi(this); dialog= new AskDialog(this); } UmerWindow::~UmerWindow() { delete ui; } void UmerWindow::on_actionAdd_Item_triggered() { dialog-&gt;show(); } void UmerWindow::showlist(QString &amp;data) { } </code></pre> <p>What should i do to resolve this problem? Please help.</p> <p><strong>PS:</strong> I also tried without inheritance, then the compiler gives me a weird <strong><em>error: ISO C++ forbids declaration of 'UmerWindow' with no type</em></strong> and <strong><em>error: expected ';' before '</em>' token*</strong> when i create an pointer object of UmerWindow in askdialog.h file. Now what should i do?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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