[英]unresolved external symbol structs
错误LNK2001:无法解析的外部符号“ public:static int WrappedVector :: _ N”(?_N @ WrappedVector @@ 2HA)
header.h
struct WrappedVector
{
static int _N;
double *_x;
};
main.cpp中
const int WrappedVector::_N = 3;
我不明白怎么了
只需更改定义
int WrappedVector::_N = 3; // Note no const
或声明
struct WrappedVector {
static const int _N;
// ^^^^^
double *_x;
};
一致。
如果需要后一种形式( static const int
),也可以直接在声明中对其进行初始化:
struct WrappedVector {
static const int _N = 3;
// ^^^
double *_x;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.