【发布时间】:2013-11-05 17:12:07
【问题描述】:
header.h
namespace VectorMath {
static FVector Make(float X, float Y, float Z);
}
文件.cpp
namespace VectorMath {
static FVector Make(float X, float Y, float Z)
{
FVector ret;
ret.X = X;
ret.Y = Y;
ret.Z = Z;
return ret;
}
}
错误
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(541): error C2129: static function 'FVector VectorMath::Make(float,float,float)' 已声明但未声明定义 1> c:\programming****\vectormath.h(19) : 参见 'VectorMath::Make' 的声明
错误将我指向 xstring(标准字符串库的一部分)第 541 行,这似乎与任何内容都没有关系。
我想指出,删除“static”会给我链接器错误,告诉我“Make”是一个未解析的外部符号...
【问题讨论】:
-
你的定义不一样。您在命名空间中声明了一个函数,并在命名空间之外定义了一个不同的函数。
-
你是否在命名空间 VectorMath 中实现了 Make
-
我确实将它们放在同一个命名空间中,抱歉更正问题。
-
从声明和定义中删除
static。
标签: c++ visual-studio