我正在使用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 Error] Assessment2.cpp(357): E2313 Constant expression required
我可以請這個幫忙嗎?
UPDATE
我問的我有下面的代碼的問題這個問題:
unsigned int arr[2] = {1,8};
unsigned int days;
TMonthCalendar->BoldDays(arr, 1, days);
MonthBoldInfo = days;
的BoldDays方法需要一個unsigned int數組,但在我只知道的價值觀運行。你可以請教我如何找到解決這個問題的方法嗎?
請說明你真正的問題。這是你的第一個還是你的更新的問題? –
pure-C中的數組*聲明*可以具有非常量大小,但不包含C++。使用一個std :: vector <>來代替,這一切都變得沒有意義。 – WhozCraig