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