因此,当我遇到一些非常奇怪的操作员匹配错误(C2677 & C2678)时,我正试图编写一个简单的相机,以便使用用户输入在游戏世界中移动。是从线上来的
camPosition += moveLeftRight * camRight;
camPosition += moveBackForward * camForward;
camTarget = camPosition + camTarget; 定义:
float moveLeftRight = 0.0f;
float moveBackForward = 0.0f;
DirectX::XMVECTOR camPosition;
DirectX::XMVECTOR camTarget;
DirectX::XMVECTOR camForward = DirectX::XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
DirectX::XMVECTOR camRight = DirectX::XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f); 这些错误如下:
Error C2677 binary '*': no global operator found which takes type 'DirectX::XMVECTOR' (or there is no acceptable conversion)
//Hovering "operand types are: float * DirectX::XMVECTOR"
Error C2678 binary '+': no operator found which takes a left-hand operand of type 'DirectX::XMVECTOR' (or there is no acceptable conversion)
//Hovering "operand types are: DirectX::XMVECTOR * DirectX::XMVECTOR" 它以前也做过汇编。当我使用命名空间DirectX时,它编译得非常好。我想当我添加一些移动代码时,可能有什么东西搞砸了。我删除了名称空间,并将DirectX::添加到每个定义和函数中。错误。用于C2677和C2678的MSDN页面根本没有帮助。谷歌只给了我一些简单的东西。
Gyazo链接:
https://gyazo.com/e2f62026d00e8fa82142b24de3fe32b5 https://gyazo.com/f1bbc321abc3a167d519bf1d671edcc6
编辑:我不知道为什么,也不知道怎么做,但现在起作用了。所以耶..。我的时间过了一个小时。>.>该死的编码..。LOL。
发布于 2017-03-20 15:18:25
您想使用这个操作符:
XMVECTOR XM_CALLCONV operator+ (FXMVECTOR V1, FXMVECTOR V2);我觉得你好像把它藏起来了:
namespace
{
class Scalar {
public:
Scalar() {}
};
inline Scalar operator+ (Scalar s1, Scalar s2) { return Scalar(); }
int f() {
XMVECTOR a;
a = a + a; // Here, you can't access XMVECTOR's operator,
// because name lookup stops with first operator found
}
}https://stackoverflow.com/questions/40626441
复制相似问题