gpt4 book ai didi

c++ - 错误 : no match for 'operator!='

转载 作者:太空宇宙 更新时间:2023-11-04 16:06:37 25 4
gpt4 key购买 nike

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);
};
};

在第 2 行,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 >()'|

我只是不允许在函数内部执行此操作还是我遗漏了什么?

最佳答案

A list<int>list<super>两个不同list .您不能将一个迭代器与另一个迭代器进行比较。

关于c++ - 错误 : no match for 'operator!=' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34231624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com