我基本上有
int x;
cout << "Please enter how many classrooms there are: ";
cin >> x;
classrooms bunchaClassrooms[x]; //classrooms is a previously declared class.
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它给出了错误'非POD元素类型'x''的可变长度数组,我不知道为什么,如果我使用教室的矢量代替,我怎么能轻松填充它(使用for循环我猜)取决于用户的输入.
例如:
int input;
cout << "Please enter how many burgers you'd like" << endl;
cin >> input;
Run Code Online (Sandbox Code Playgroud)
什么是缩短“输入”和只接受前两个最简单的方法位数字。继续这个例子:
用户输入:432534。输入值:43。
用户输入:12342342341234123412341235450596459863045896045。输入值:12。
(编辑:说“数字”而不是“位”)