在初始化浮点数组时,c++交叉初始化跳转到case标号
c++ cross initialization jump to case label when initializing a float array
我有3个类M, L, p,每个类都有自己的。header和。cpp用于封装实践,我在每个。header和。cpp中分别放置了相关的函数和属性
我有这个函数float L::calculate(arg,arg,arg,arg)
这里是在L.cpp,它只是一个固定的公式,参数取自类本身。但是我有另一个类P
在p .cpp中,我得到了L类的计算函数的集合。在类P中,我也有构造函数,1默认和1接受参数(我也在两个构造函数中初始化L)
然后在我的类M中所有的实现集合在一起。
我正在尝试创建一个像这样的浮点数组:
float calculateThis[size]; // the size is fixed at 50.
然后在for循环中,x小于size
i did this:
calculateThis[x] = newL[x].caculate(args,args,args,args);
newP.setCalculate(calculateThis[x]);
++x;
我还声明了top
L newL[size]; //Used for some other methods that i have wrote to get inputs and save it .
P newP[size];
当我编译时,我得到这个错误:
crosses initialization of ‘float calculateThis[size]’
float calculateThis[size];
基本上我试图保存计算函数,返回一个浮点数到一个浮点数组
编辑: switch(choice)
{
case 1: // 1st Choice.
while(entry<size)
{
//getting user input and saving it by newL.set / newP.set
};
break;
case 2:
float calculateThis[size]; // the size is fixed at 50.
for(x=0,x<size)
{ calculateThis[x] = newL[x].caculate(newL.get(),newL.get(),newL.get(),newL.get());
newP.setCalculate(calculateThis[x]);
++x;
}
break;
default:break;
}
使用括号表示这是calculateThis
的局部作用域:
case 2:
{
float calculateThis[size]; // the size is fixed at 50.
for(x=0,x<size)
{
calculateThis[x] = newL[x].caculate(newL.get(),newL.get(),newL.get(),newL.get());
newP.setCalculate(calculateThis[x]);
++x;
}
}break;
相关文章:
- 是否可以初始化不可复制类型的成员变量(或基类)
- C++使用整数的压缩数组初始化对象
- C++初始化基类
- 多成员Constexpr结构初始化
- 复制列表初始化的隐式转换的等级是多少
- 内联映射初始化的动态atexit析构函数崩溃
- 如何在C++中初始化嵌套类中的2个memeber
- 如何声明特征矩阵,然后通过嵌套循环初始化它
- 没有用于初始化C++中的变量模板的匹配构造函数
- 在未初始化映射的情况下,将值插入到映射的映射中
- C++成员初始化
- 为什么在C++中首先初始化成员类
- 同时具有"聚合初始化"和"模板推导"
- 初始化具有非默认构造函数的std::数组项的更好方法
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 我可以使用条件运算符初始化C风格的字符串文字吗
- 在初始化浮点数组时,c++交叉初始化跳转到case标号
- c++变量初始化在SWITCH语句中DEFAULT之后的CASE内
- 如何解决此错误:跳转到case标签交叉初始化
- 'element'的初始化被'case'标签跳过