我正在尝试将结构传递给函数,并遇到错误“预期的主表达式在'之前。”。令牌”。我不知道如何通过该结构?任何帮助深表感谢!
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;
}
}
答案 0 :(得分:0)
在代码的某些行,您将vendingMachines用作Machines的对象
machines.vendingMachines[2].drinkTypes[i].drinkSize
在其他几行中,您没有将vendingMachines用作Machines的对象
vendingMachines[2].drinkTypes[i].drinkName
尽管如此,我看不到任何有关VendingMachines是Machines对象的声明。