c++ - 错误 : invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator/’

标签 c++ operator-overloading

在 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/

相关文章:

php - 使用 WordPress 在 Web 服务器上运行 C++ 应用程序

exception-handling - 如何在 F# 中实现空安全运算符

c++ - 重写 [] C++

c++ - 如何将 C 库用于 Arduino 代码

c++ - OpenCv 未定义对 `cv::的引用

c++ - 这个环路优化配置文件意味着什么?

c++ - 重载 << 运算符的问题

C++重载operator+和动态内存分配

pointers - 通过指针访问类型后派生类型中 Fortran 字符串的奇怪行为

c++ - 原始 C++ 内存逻辑的奇怪行为