Tareen
Tareen

Reputation: 21

C2143: syntax error: missing ';' before '*' & C4430: missing type specifier - int assumed. Note: C++ does not support default-int

First of all, i've seen some solutions, but i didn't understand them. I am a total Newbie in QT and even Google didn't helped me. English is not my first language

This is the error message after debugging in QT Creator 5.6

C2143: syntax error: missing ';' before '*'

C4430: missing type specifier - int assumed. Note: C++ does not support default-int

C2238: unexpected token(s) preceding ';'

here is the file

secdialog.h

#ifndef SECDIALOG_H
#define SECDIALOG_H

#include <QDialog>
#include "tridialog.h"
#include "quadialog.h"

namespace Ui {
class SecDialog;
}

class SecDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SecDialog(QWidget *parent = 0);
    ~SecDialog();

private slots:
    void on_pushButton_5_clicked();

    void on_status_clicked();

    void on_pushButton_2_clicked();

    void on_zuteilung_clicked();

private:
    Ui::SecDialog *ui;

    TriDialog *triDialog;  //this is the line with the problem

    QuaDialog *quaDialog;  // funny thing, he didn't complain about this line

};

#endif // SECDIALOG_H

Sorry if the problem was already here in the questions, but i didn't understand the other solutions.

I'm trying to make a little program just for show, it only needs to show some forms and thats it. There are some buttons and every button opens another form and hides the one before.

My problem is, i always have my problems with programming and languages, often i don't know enough to understand a solution, i'm more a "someone shows me how and then i use it and understand it" - i learn through "copy paste"

Could anyone tell me what i did wrong? If you need more information about the project, just ask.

Thank you in advance.

Here the the requested tridialog.h

#ifndef TRIDIALOG_H
#define TRIDIALOG_H

#include <QDialog>
#include "secdialog.h"


namespace Ui {
class TriDialog;
}

class TriDialog : public QDialog
{
    Q_OBJECT

public:
    explicit TriDialog(QWidget *parent = 0);
    ~TriDialog();

private slots:
    void on_pushButton_5_clicked();

private:
    Ui::TriDialog *ui;
    TriDialog *triDialog;
};

#endif // TRIDIALOG_H

Here is the whole project for qt kraftwerk.zip

Upvotes: 2

Views: 3924

Answers (2)

skearney
skearney

Reputation: 126

Your problem is in tridialog.h:

#include "secdialog.h"

When you include secdialog.h, you bring in your SecDialog class declaration, which has a TriDialog pointer (on the problematic line) before the TriDialog class is declared!

Since you don't actually need anything from secdialog.h in tridialog.h, just remove

#include "secdialog.h"

and it should work.

Upvotes: 3

Kyle A
Kyle A

Reputation: 980

It looks like you have a scoping error, unless I'm misunderstanding your intent. This code:

namespace Ui {
    class TriDialog;
}

class TriDialog : public QDialog
{};

declares a class named TriDialog in the namespace Ui and then declares a class named TriDialog outside the namespace Ui. You now have two classes, Ui::TriDialog and TriDialog. You need to put the whole definition inside the namespace scope.

Edit: Looks like skearney found the error you were asking about, but this is still an issue.

Upvotes: 1

Related Questions