0
兩者都在運營商=在同一類不能從2D陣列到另一個2D陣列做一個strcpy
這裏是函數的定義。下面
void segment::operator=(const segment& w) {
strcpy(this->phrase, w.getPhrase()); //this line creates a problem.
錯誤是:
segment.cpp: In member function ‘void segment::operator=(const segment&)’:
segment.cpp:186: error: passing ‘const segment’ as ‘this’ argument of ‘const char*
segment::getPhrase()’ discards qualifiers
segment.cpp:186: error: cannot convert ‘char (*)[40]’ to ‘char*’ for argument ‘1’ to ‘char* strcpy(char*, const char*)’
const char* segment::getPhrase(){
return *phrase;
}
及以上功能getPhrase
我不知道爲什麼我不能爲做一個strcpy的。
我正在嘗試完成作業。
編輯:
這是phrase
char phrase[10][40];
什麼是變量「短語」的確切類型更換
10
? – Itaypk 2012-07-27 20:06:24問題更新@Itaypk謝謝! – Ali 2012-07-27 20:07:24