我该如何解决这三个错误?在数组声明上编译错误?
- 错误C2057:预期常量表达式
- 错误C2466:不能分配恒定大小0
- 错误C2133的数组: 'randomTickets':未知尺寸真实遇到的问题
线和不顺心[机票]
int randomTickets[tickets][SIZE];
//global constants
const int SIZE = 6; //This is the number of balls per ticket
const int MAX_WHITE = 58; //This is the range of the white balls
const int MAX_RED = 34; //This is the range of the red balls
const int waysToWin = 9;
int* newAr = new int[SIZE];
int main(int argc, const char * argv[])
{
int tickets = displayMenu(); //Welcome screen lets you buy tickets
int spending = tickets * 2; //Charges you for the tickets
int randomTickets[tickets][SIZE];
//code
在此先感谢您的帮助!
使'票据'一个常数表达式,并确保它的价值e大于零。 –
你能解释一下你不明白的错误信息部分吗? “预期的常量表达式”非常简单。难道你不知道它在哪里? (你似乎知道这一点,因为你将它隔离为“票”。)难道你不知道一个常量表达是什么? –
'std :: vector> randomTickets(票);'(和雷蒙德的评论+1)。 –
WhozCraig