errors.txt
来自「为SSD5课程《数据结构与算法》中的练习」· 文本 代码 · 共 44 行
TXT
44 行
Bug #1
-----------------------------
Line
"void build_wordlist (string* word_list, int capacity, string filename)"
must be changed to
"void build_wordlist (string*& word_list, int& capacity, string filename)"
because
fuction build_wordlist should read words into word_list,so word_list and capacity should be passed by reference.
Bug #2
-----------------------------
Line
"new_word_list = word_list[index];"
must be changed to
"new_word_list[index] = word_list[index];"
because
new_word_list is a pointer,the copy can be finished only if every memory location is changed to the correct assignment.
Bug #3
-----------------------------
Line
"string new_word_list = *(new string[2 * capacity]);" and "*word_list = new_word_list;"
must be changed to
"string *new_word_list = new string[2 * capacity];" and "word_list = new_word_list;"
because
we must store the address of the new list in the pointer new_word_list.
Bug #4
-----------------------------
Line
"delete word_list;
must be changed to
"delete []word_list;"
because
deleting an array must be written like this "delete []'指向数组的指针';".
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?