Globals are evil. Alas, the idiomatic way to do it is:
- Declare the global variable extern in a header file.
- Define the variable in one source file (and no more). Include the declaration from the header to ensure the definition is correct.
- Use the variable in any number of source files; include the declaration from the header.
global.h
#ifndef BENHUAN_GLOBAL_H_INCLUDED
#define BENHUAN_GLOBAL_H_INCLUDED
#include <QPoint>
extern QPoint point[5][6]; // declaration
#endif
global.cpp
#include "global.h'
QPoint point[5][6]; // definition
main.cpp
#include "global.h"
...
point[1][2] = QPoint(5,6);