错误:“int”和“<未解析的重载函数类型>”类型的无效操作数到二进制“operator/”

Posted

技术标签:

【中文标题】错误:“int”和“<未解析的重载函数类型>”类型的无效操作数到二进制“operator/”【英文标题】:error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator/’ 【发布时间】:2012-06-15 11:01:08 【问题描述】:

在 SENSE SIMULATOR 中运行此代码时,我遇到了下面提到的 2 种错误。 错误如下 -

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:在函数'int main(int, char**)'中:

sensim.cc:189:20:错误:无效使用成员(您忘记了“&” ?)

sensim.cc:201:46:错误:无效使用成员(你忘记了'&' ?)

sensim.cc:215:57:错误:无效使用成员(你忘记了'&' ?)`

此部分出现此错误:

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 种错误......

任何人都可以帮助我,为什么当同一个文件与旧版本完美运行时,这 2 个错误会奇怪地出现。

问候,

苏形

【问题讨论】:

告诉我们SensorSimStopTimePacketSize 【参考方案1】:

听起来StopTime 是一个函数。这可以解释这两个错误。

【讨论】:

以上是关于错误:“int”和“<未解析的重载函数类型>”类型的无效操作数到二进制“operator/”的主要内容,如果未能解决你的问题,请参考以下文章

<未解析的重载函数类型> 带有成员函数指针和模板

另一个类中使用的非静态类<未解析的重载函数类型>

VB6:运行时错误“13”:设置和 int 时类型不匹配 int

类型错误:+ 不支持的操作数类型:“int”和“元素”

为啥它显示像 ld 返回 1 退出状态和未定义的引用 `powr(int, int)' 之类的错误

类型错误:** 或 pow() 不支持的操作数类型:'str' 和 'int'