没有运算符"[]"匹配这些操作数/没有模板化代码
No operator "[]" matches these operands / no templated code
im试图在此问题中修复示例代码:如何将3D点转换为2D透视投影?
我已经解决了大多数错误,但是一个人让我感到困惑。
有一个class矩阵,带有[]运算符
float& operator[]( size_t index )
{
if (index >= 16) {
std::out_of_range e( "" );
throw e;
}
return data[index];
}
我在此代码上获得了一个非匹配操作员错误:
inline Vector operator*( const Vector& v, const Matrix& m )
{
Vector dst;
dst.x = v.x*m[0] + v.y*m[4] + v.z*m[8] + v.w*m[12];
dst.y = v.x*m[1] + v.y*m[5] + v.z*m[9] + v.w*m[13];
dst.z = v.x*m[2] + v.y*m[6] + v.z*m[10] + v.w*m[14];
dst.w = v.x*m[3] + v.y*m[7] + v.z*m[11] + v.w*m[15];
return dst;
}
我无法弄清楚操作员定义有什么问题。
在提出问题后,精确30秒,它遇到了我的operator*
正在接收 const 矩阵对象。
问题是operator[]
不是const函数。
在此处留在这里,因为Google上只有两个不同的问题 -
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- GCC 带内联汇编和 -Ofast 为内存操作数生成额外的代码
- 没有运算符"[]"匹配这些操作数/没有模板化代码
- Visual studio:E0349 没有运算符<<匹配这些操作数(但代码中没有字符串)
- 编译逗号运算符的 C++ 代码右操作数中的错误不起作用
- 如何计算重载运算符在具有特定类型操作数的代码库中使用的次数
- 将.cpp更改为 .cu 后,>> C++ 代码中无法识别基本操作数
- 汇编程序代码,错误 C2443:操作数大小冲突
- 将C++代码从 VS2003 迁移到 VS2010 后出现错误 C2678,错误 C2679:二进制'=':未找到采用类型为 'int' 的右侧操作数的运算符
- 收到错误:将我的 c++ 代码从 Linux 移植到 android 时'asm'中的操作数约束不一致