错误:'operator!='不匹配
Error: no match for 'operator!='
void super::findTarget(list<int>Dlist,list<super>::iterator t){
while(t != Dlist.end()){
double mypos[3];
double target[3];
double fpos[3];
double speed;
double range;
double a, b, c, D;
mypos[0]=this->x;
mypos[1]=this->y;
mypos[2]=this->z;
range = this->range;
target[0]=t->x;
target[1]=t->y;
target[2]=t->z;
a = target[0]-mypos[0];
b = target[1]-mypos[1];
c = target[2]-mypos[2];
D = sqrt( pow(a,2.0)+pow(b,2.0)+pow(c,2.0));
Dlist.push_back(D);
};
};
在第二行,while (t != Dlist.end(){
,我收到以下错误:
我C:\Users\Daniel\Desktop\project\super.cpp|369|error: no match for 'operator!=' in 't != Dlist.std::list<_Tp, _Alloc>::end>(('|
只是不允许在函数内执行此操作还是我错过了什么?
list<int>
和list<super>
是两种不同的list
。 不能将一个迭代器与另一个迭代器进行比较。
我认为你不应该比较list<int>::iterator
和list<super>::iterator
.没有 != 运算符将这两种不同的类型作为参数。
相关文章:
- 与'operator='不匹配(操作数类型'String'且"void")
- Valarray 切片数组与 'operator*' 不匹配
- 错误:'operator>'不匹配(操作数类型为 'Student' 和 'Student'
- 与'operator<<'不匹配(操作数类型'std::ostream {aka std::basic_ostream<char>}'
- 与"operator<<"不匹配(操作数类型'std::ostream'
- C++ 重载:[错误] 与'operator='不匹配(操作数类型为 'String' 和"字符串")
- 使用标准::时间::high_resolution_clock时"operator ="不匹配
- 错误:与'operator='不匹配(操作数类型为 'PlDrustvo' 和"PlDrustvo")|
- 错误:与'operator='不匹配(操作数类型为"std::map<int、double>::iterator
- 错误:尝试减去字符串时'operator-'不匹配
- 调用模板方法会导致'operator<'不匹配
- \main.cpp|103|error: 与"operator<<"不匹配(操作数类型为"std::ostream {aka std::basic_ostream<char&g
- 使用 #omp 时'operator -'不匹配
- 尝试使用 fstream 将字符写入文件:'operator<<'不匹配
- C++ 将文件读取到数组错误:'operator>>'不匹配
- 有没有办法修复此错误:与'operator[]'不匹配(操作数类型为 'empl' 和"int")
- 错误与'operator='不匹配(操作数类型为 'Person' 和"Person*")
- 我得到"将值分配给结构数组 iin 时与'operator='不匹配C++
- 在地图中搜索值时'operator='不匹配
- 错误:'operator<<'和"运算符>>"不匹配。请帮忙?