私はソート機能を持っています:
void countingSort(TPhone * const * array, int count) {
// some code
// making copy od array
TPhone * const * arrayCopy = new TPhone * [count];
for(int i = 0; i < count; i++) {
arrayCopy[i] = array[i];
}
for(int i = 0; i < count; i++) {
int index = // some function to determine where to place array[i]
array[index] = arrayCopy[i];
}
}
問題は別の場所にあるため、並べ替えアルゴリズムの詳細は省略しました。問題は、 の宣言に問題がありarrayCopy
ます。
オンライン
arrayCopy[i] = array[i]
...
array[index] = arrayCopy[i];
このエラーメッセージが表示されます
error: assignment of read-only location ‘*(arrayCopy + ((sizetype)(((long unsigned int)i) * 8ul)))’
error: assignment of read-only location ‘*(array + ((sizetype)(((long unsigned int)index) * 8ul)))’
宣言の使用法に問題があるに違いありませんがconst
、修正方法がわかりません...