结构,数组错误 C2512
Struct, Array Error C2512
我正在尝试为我的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();
据我所知,这应该有所帮助。
相关文章:
- 错误 C2512 视觉C++(并且不是循环依赖项)
- 错误 C2512:没有可用的适当默认构造函数:在构造函数中声明带有参数的对象!
- c++ 错误错误 C2512 没有合适的默认构造函数可用
- C2512 错误 - 即使未初始化类
- C2512错误:没有适当的默认构造函数可用
- 错误 C2512 和 C3892 - 像游戏一样构建吃豆人
- 错误 C2512 'DerivedClass':没有可用的适当默认构造函数
- 错误C2512没有合适的默认构造函数,即使我有一个
- 错误 C2512:没有可用的适当默认构造函数(不是类)
- 预编译头文件中出现错误 C2512
- 结构,数组错误 C2512
- 在构造函数调用中收到错误 C2512
- 错误C2512没有合适的默认构造函数可用
- 没有显式构造函数的结构中出现错误C2512
- 错误C2512:没有合适的默认构造函数可用
- 错误C2512,但我有可用的默认构造函数
- 错误C2512:没有合适的默认构造函数可用
- 为什么我得到错误c2512:没有适当的默认构造函数可用
- 错误 C2512:'std::basic_ostream<_Elem,_Traits>':没有适当的默认构造函数可用于仅 Visual Studio
- c++错误c2512:没有可用的默认构造函数