小编use*_*810的帖子

'当多个重载函数实例"sqrt"匹配参数列表'时,我该怎么办?

我在for循环中的代码中出错,for ( j = 3; j <=sqrt(num); j +=2):

多个重载函数"sqrt"的实例与参数列表匹配.

我该如何解决?

# include <cmath>

// determine if number is prime
bool isPrime (long n) 
{
  int j, num = 0;
  {
    if (num <=1)
      return false;
  }
  for ( j = 3; j <=sqrt(num); j +=2)
  {
    if (num % j == 0)
      return false;
  }   
  return true;
}
Run Code Online (Sandbox Code Playgroud)

c++ overloading sqrt

4
推荐指数
1
解决办法
8164
查看次数

标签 统计

c++ ×1

overloading ×1

sqrt ×1