我正在尝试用 C++ 编写井字游戏,但每当我运行它时,我都会收到一条错误消息:
TicTacToe.cpp: In instantiation of ‘void copy_array(T*, T*) [with T = std::basic_string<char>]’:
TicTacToe.cpp:115:25: required from here
TicTacToe.cpp:93:3: error: no match for ‘operator*’ in ‘**(new_arr + ((sizetype)(((long unsigned int)i) * 8ul)))’
它指向这个函数:
86 template<class T>
87 void copy_array(T old_arr[], T *new_arr)
88 {
89 int size = sizeof(old_arr)/sizeof(old_arr[0]);
90 for(int i = 0; i < size; i++)
91 {
92 *new_arr[i] = old_arr[i];
93 }
94 }
一段代码:
114 string copy[9];
115 copy_array(board, copy);
谁能向我解释导致错误的原因以及如何解决?