I have a header file and 3 cpp files. I want to share an array object between my files to store data in it and use it (global variable).
My header file code : info.h
#ifndef INFO_H
#define INFO_H
#include "QString"
class ib
{
public:
QString from,to,seat[32],driver;
}extern o[10];
#endif // INFO_H
and my cpp files code : bilit.cpp
#include "info.h"
void bilit::on_pushButton_clicked()
{
const int f = ui->bnspin->value();
const int s = ui->stspin->value();
o[f].seat[s] = ui->pnbtn->text();
}
make.cpp
#include "info.h"
void make::on_pushButton_clicked()
{
const int f = ui->spinBox->value();
o[f].driver = ui->drvbtn->text();
o[f].to = ui->tobtn->text();
o[f].from = ui->frombtn->text();
}
check.cpp
#include "info.h"
void check::on_pushButton_clicked()
{
const int f = ui->spinBox->value();
const int s = ui->spinBox_2->value();
ui->label->setText(o[f].seat[s]);
}
and this is my error : error
even i write extern in my cpp files but i get error again : error2
any idea how to fix it ? or other way to share a global variable between my files ?