在 SENSE SIMULATOR 中运行我的代码时,我遇到下面提到的两种错误。 报错如下——
sensim.cc:137:23: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator/’
sensim.cc:138:23: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator/’
出现此错误的行如下所示 -
137. tp_sent = (sent / StopTime) * (PacketSize); // line 137
138. tp_recv = (recv / StopTime) * (PacketSize); // line 138
而第二种错误是
`sensim.cc: In function ‘int main(int, char**)’:
sensim.cc:189:20: error: invalid use of member (did you forget the ‘&’ ?)
sensim.cc:201:46: error: invalid use of member (did you forget the ‘&’ ?)
sensim.cc:215:57: error: invalid use of member (did you forget the ‘&’ ?)`
此部分出现此错误:
int main(int argc, char* argv[]){
SensorSim sim;
long int seed; // line 189
sim.StopTime = 1000;
PRINT = 0;
ESCENARIO = 0; // line 201
// You can fix the seed to obtain the same results each time you simulate. If you set it to time(0) be aware that the same results will be obtained for short (less than 1 second) simulations
if(seed == 0) seed=time(0);
// line 215 though this line is blank in my code
sim.Seed = seed;
printf("StopTime: %.0f, Number of Nodes: %d, Area: %.0f by %.0f Seed %ld\n",
sim.StopTime, sim.NumNodes, sim.MaxX, sim.MaxY, seed);
printf("Packet Size: %d, Interval: %f\n\n",
PacketSize, Interval);
现在,同一个文件在 sense 2.0 版中运行得很好,但是当我在 sense 3.1 版中运行文件时,我遇到了这两种错误....
任何人都可以帮助我为什么当同一个文件与旧版本完美运行时这 2 个错误会奇怪地出现。
问候,
草形
最佳答案
听起来 StopTime
是一个函数。这可以解释这两个错误。
关于c++ - 错误 : invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator/’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11049412/