如何使它成为全局对象数组,如QPoint point [5] [6];
global.h
#include <QPoint>
extern QPoint point[5][6];//Am I correct?
global.cpp
#include <global.h> // How to initialize???
的main.cpp
#include <global.h>
use them;
答案 0 :(得分:3)
全球是邪恶的。唉,惯用的方法是:
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);