我正在使用 C++ Builder,并且在将 const int 变量设置为向量的大小方面得到了一些帮助。
这是我的有效代码,只是为了向您展示什么有效:
vector<appointment> appointmentVector = calCalendar.getAllAppointments();
const int sizeOfArray = 5;
unsigned int arr[sizeOfArray];
如果我将代码修改为以下内容:
vector<appointment> appointmentVector = calCalendar.getAllAppointments();
const int sizeOfArray = appointmentVector.size();
unsigned int arr[sizeOfArray];
我收到以下错误:
[BCC32 错误] Assessment2.cpp(357): E2313 需要常量表达式
我可以帮忙吗?
更新
我在问这个问题时遇到以下代码问题:
unsigned int arr[2] = {1,8};
unsigned int days;
TMonthCalendar->BoldDays(arr, 1, days);
MonthBoldInfo = days;
BoldDays 方法需要一个无符号整数数组,但我只知道运行时的值。你能告诉我如何找到解决这个问题的方法吗?