结构,数组错误 C2512

Struct, Array Error C2512

本文关键字:C2512 错误 数组 结构      更新时间:2023-10-16

我正在尝试为我的C++课做作业,但被卡住了。我关注了这本书,并在互联网上搜索了答案,但达不到要求。我需要在结构中有一个数组,该数组将向客户显示带有价格的早餐菜单。他们会选择他们想要的东西,当他们完成后,它会显示他们的账单。这是我到目前为止所拥有的,由于错误,这并不多。

#include "stdafx.h"
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int  main()
{
cout << fixed << setprecision(2);
const string menuList[9]
{ "Plain Egg", "Bacon and Egg", "Muffin", "Frech Toast", "Fruit Basket",       "Cereal", "Coffee", "Tea" };
double prices[9]
{1.45, 2.45, 0.99, 1.99, 2.49, 0.69, 0.50, 0.75};
struct menuItemType
{
    const string menuList[9];
    double price;
    double tax;
};
menuItemType guestList;
system("pause");
return 0;
}

你应该在 main 上方声明你的结构。然后主要称它为类似

menuItemType* guestlist = new menuItemType();

据我所知,这应该有所帮助。