Declare the same namespace in two different headers and then include them in one cpp

Holla, in the Qt 5 project auto-generated files from QtCreator. There is a Ui namespace declaration in two separate headers, and both are included in the same cpp file.

//mainwindow.h
namespace Ui {
class MainWindow;
}



//ui_mainwindow.h
namespace Ui {
class MainWindow: public Ui_MainWindow {};
int x;
}


//mainwindow.cpp
#include "ui_mainwindow.h"
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

} 

I wonder what happens with the namespace? is it combined and why is this not considered an override of the MainWindow class? Thanks in advance.

Thanks for your answers, and I found an article on headings, including

+4
source share
3 answers
  • He is merging.

  • class MainWindow; - , ; , " , , ".

    , , , , . () .

+4

, . . , : , . - .

Ui::MainWindow mainwindow.h . . , , . ui_mainwindow.h Ui::MainWindow. .

+2

, Qt.

++. , .

, .

. , , :

Namespaces

MainWindow?

class MainWindow;

, . , . , .

:

0

All Articles