在C++中使用命名空间中的全局变量,如何声明,才不会重复定义呢?
(1)在test.h 中声明
namespace try
{
extern double gCameraMatrix[9];
extern double gDistCoeffs[4];
}
在test.cpp中定义
namespace try
{
double gCameraMatrix[9];
double gDistCoeffs[4];
}
在main.cpp中使用,
#include"test.h"
using namespace try;
即可使用该命名空间中的全局变量