将结构传递给函数时遇到问题
Running into issues when passing struct to function
我正在尝试将结构传递给函数并遇到错误"'.标记之前的预期主表达式"。我不知道我将如何传递结构?任何帮助都非常感谢!
void check(std::string buildingName, int floorLevel, std::string drinkName, float drinkSize, struct machines)
{
bool correct = true;
if (buildingName == "Snell")
{
if (floorLevel == 1 || floorLevel == 3)
{
if (floorLevel == 1)
{
for (int i = 0; i < 10; i++)
{
if (machines.vendingMachines[0].drinkTypes[i].drinkName == drinkName && machines.vendingMachines[0].drinkTypes[i].drinkSize == drinkSize)
{
correct = true;
}
}
}
else
{
for (int i = 0; i < 10; i++)
{
if (machines.vendingMachines[2].drinkTypes[i].drinkName == drinkName && machines.vendingMachines[2].drinkTypes[i].drinkSize == drinkSize)
{
correct = true;
}
}
}
}
else
{
correct = false;
}
}
else
{
correct = false;
}
}
在代码的某些行中,您使用自动售货机作为机器的对象
machines.vendingMachines[2].drinkTypes[i].drinkSize
在其他一些行中,您没有使用自动售货机作为机器的对象。
vendingMachines[2].drinkTypes[i].drinkName
尽管如此,我没有看到任何声明自动售货机是结构机器的对象。
相关文章:
- 编译包含字符串的代码时遇到问题
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- 从其他类访问类时遇到问题
- 使用静态成员声明类时遇到问题
- C++ 填充数组时遇到问题
- 在将字符串放入字符串向量时遇到问题?
- 余数除法和不允许除以零 (c++) 时遇到问题
- 我在C++中使用 getline() 函数时遇到问题
- C++线程安全:如果只有一个线程可以写入非原子变量,但多个线程从中读取. 会遇到问题吗?
- 在我的四叉树实现中遇到问题
- 在 c++ 中循环遍历数组时遇到问题
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 编译 Cilk Plus 程序时遇到问题
- 存储另一个函数返回的布尔数组时遇到问题
- 我在 OpenGL 中显示图像时遇到问题
- 我在解决此错误时遇到问题.我正在努力在主函数中传递数组
- 在 for 循环中更新两个变量时遇到问题C++
- 为什么我的程序在打开网络设备时遇到问题
- 在 Tensorflow C++ 中使用 FIFOQueue 时遇到问题
- 为什么我在虚幻引擎中的多态性和接口方面遇到问题?