SuperFHC666
SuperFHC666
2020-03-01 23:05

Qt编译报错,请各位大佬帮忙解决一下,谢谢

20
  • c++

Qt小白,写代码的时候在定义全局变量的时候发生了问题,请大佬帮忙解决一下,谢谢

相关报错信息:

报错

mainwindow.h

mainwindow.h

mainwindow.cpp

图片说明

mainwindow.h

mainwindow.cpp

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QString>
#include <allinall.h>
#include <winborrow.h>
#define M 11
#define MAXN 1000000
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    struct position{
        int area;
        int row;
    };
    static struct BooksA{
        QString ISBN="-1";
        QString name="-1";
        position pos;
    }bookA[MAXN],init;
private slots:
    void on_BorrowBTN_clicked();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H


------------------------------------------------------------


#include <mainwindow.h>
#include <ui_mainwindow.h>
#include <bits/stdc++.h>
#define M 11
#define MAXN 1000000
MainWindow::BooksA MainWindow::bookA[MAXN];
bookA[1].ISBN="12345";
bookA[2].ISBN="54321";
bookA[1].name="宝可梦图鉴";
bookA[2].name="武林外传";
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}
//int main(int argc, char *argv[]){
//    ifstream input;
//    input.open("D:\\SESbooktest.txt");
//    input>>n
//    for(int i=1;i<=n;i++){
//        QString loca1,loca2;

//        input>>WinBorrow::bookA[i].ISBN>>WinBorrow::bookA[i].name>>WinBorrow::bookA[i].pos.area
//    }
//}

void MainWindow::on_BorrowBTN_clicked()
{
    WinBorrow *winborrow;
    winborrow = new WinBorrow;
    winborrow->show();
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答