字典程序,但是为什么编译时有left operand must be l-value这个错误,希望大家解决呀
#include "iostream.h"#include "fstream.h"
#include "string.h"
#define MAX 1000
struct WORD
{
char english[10];
char chinese[20];
};
class dictionary
{
private:
WORD word[MAX];
public:
int i;
dictionary();
void inputword();
void inputword(char wor[10]);
void checkword();
void showdic();
void alter();
friend ostream &operator<<(ostream &out,WORD word);
};
dictionary::dictionary()
{
i=1;
}
void dictionary::inputword()
{
if(i>MAX)return;
cout<<"请输入单词:";
cin>>word[i].english;
cout<<"请输入单词中文意思:";
cin>>word[i].chinese;
i++;
}
void dictionary::inputword(char wor[10])
{
if(i>MAX)return;
strcpy(word[i].english,wor);
cout<<"请输入中文意思:";
cin>>word[i].chinese;
i++;
}
void dictionary::checkword()
{
bool isfind=false;
char wordcheck[20];
cout<<"请输入你要查找的单词:";
cin>>wordcheck;
for(int j=1;j<=i;j++)
{
if(strcmp(wordcheck,word[j].english)==0)
{
cout<<"中文意思:"<<word[j].chinese;
isfind=true;
}
}
if(!isfind)
{
cout<<"单词没有找到!"<<endl;
inputword(wordcheck);
}
}
ostream &operator <<(ostream &out,WORD word)
{
cout<<"enlish:"<<word.english;
cout<<" ";
cout<<"中文:"<<word.chinese<<endl;
return out;
}
void dictionary::showdic()
{
int m;
for(m=1;m<i;m++)cout<<word[m];
}
void dictionary::alter()
{
char alterword[10];
bool isfind=false;
cout<<"请输入你想修改的单词:";
cin>>alterword;
for(int p=1;p<i;p++)
{
if(strcmp(word[p].english,alterword)==0)
{
char alterchinese[20];
cout<<"输入你想修改的中文意思:";
cin>>alterchinese;
word[p].chinese=alterchinese;
isfind=true;
}
}
if(isfind==false)cout<<"没有找到这个单词!请重新输入:"<<endl;
}
void main()
{
dictionary dic;
int n,m=1;
cout<<".......................字典..........................."<<endl;
cout<<"1..............输入单词.............................."<<endl;
cout<<"2..............查单词................................"<<endl;
cout<<"3..............显示字典库............................"<<endl;
cout<<"4.............修改单词............................,.."<<endl;
cout<<"5...............退出.................................."<<endl;
while(m)
{
cin>>n;
switch(n)
{
case 1: dic.inputword();break;
case 2: dic.checkword();break;
case 3: dic.showdic();break;
case 4: dic.alter();break;
case 5: m=0;break;
}
}
}
编译时程序上面显示“蓝色”字体的错误,为什么呀?怎么解决呀?我的作业呀,希望大家帮帮小弟的忙呀!