在此范围内未声明"y",
'y' was not declared in this scope,
我对这个项目有很多问题,我想出了很多。 但是这个我不能
在这里我有一些计算,然后我需要这个"y"变量传递给下一个.cpp
#include <iostream>
#include <math.h>
using namespace std;
int Ing(int number, float y)
{
y = 0;
float Lngth = 0;
for(; number != 0; number /= 10, Lngth++);
float n = nearbyint(sqrt(Lngth));
y = Lngth * pow(10, n);
return (y);
}
这是下一个.cpp
#include <iostream>
#include "InitialGuess.h"
#include <math.h>
using namespace std;
int SquareRoot(int number, int th)
{
float iGuess = Ing(y);
float x = iGuess;
for (int k=1; k< th; ++k)
{
x = (x + (number / x ))/2;
}
cout<<x;
return (x);
}
但是在编译时,它给了我错误,即"y"未在此范围内声明。我哪里犯了错误?
谢谢
在此行
float iGuess = Ing(y);
您没有声明 Y,这会导致错误。你想传递给 Ing() 什么值?
您为 Ing(int, float) 定义了 2 个参数,但只用一个参数调用它。
y = 0;
应该是
int y = 0;
因为此时尚未声明y
并且您正在定义一个变量。
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 我在范围内未声明的错误类有问题
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- 如何修复未在范围内声明
- 在 mingw64- 变量下的窗口中编译 openvpn3 时出错,未在范围内声明
- 未在范围内声明'OBJECT'
- 在标头中声明时,变量未在范围内声明
- 2d 数组中大于 10^5 的值未在范围内声明
- C++ - "(常量字符*)"未在范围内声明?
- 未在范围内声明 - priority_queue C++的友元比较器类
- 尝试和捕获中的对象声明未在范围内定义
- 未在范围内声明.多个错误
- C++ 错误:未在范围内声明;成员函数
- 未在范围内声明'init_s1_value'
- C++代码块 |我在编译时不断收到相同的消息" .......未在范围内声明。如何在范围内声明某些内容?
- 未在范围内声明,即使在 .h 中声明也是如此
- 如何在类声明范围内使用“using space::function”