我不明白這個錯誤。爲什麼我不能使用操作員刪除我的條目?幫助我做到這一點。這是我的書入門級,'operator ='in'((library *)this) - > library :: database [bookcode] = -1'|
class bookEntry{
public:
int code;
int copies;
char name[30];
char author[30];
};
,這是我的類庫
class library{
public:
int numBooks;
bookEntry database[MAX], tempdatabase[MAX];
library(){
numBooks = 0;
}
void insertBook(int bookcode, char bookName[], char author[], int bookcopies);
void deleteBook(int bookcode);
void search(int bookcode);
void displayBook();
void edit(int bookcode);
void editname(int numBooks);
void editauthor(int numBooks);
void editcopies(int numBooks);
};
,這是我刪除的條目的void函數,
void library::deleteBook(int bookcode)
{
system("cls");
cout<<endl;
cout<<"Enter A Code of a Book To Delete That Entry ";
cin>>bookcode;
cout<<endl;
int i;
for(i=0;i<=numBooks-1;i++)
{
if (bookcode==database[i].code)
{
database[bookcode]=-1;
cout<<"Book Successfully Deleted...!!"<<endl;
}
else
{
cout<<"Book not found...!!!"<<endl;
}
}
getch();
}
這是行,其中即時獲取錯誤,
database[bookcode]=-1;
那麼我應該怎麼做才能刪除所選條目 – user3549302
什麼都沒有。你不能「刪除」數組元素。你將不得不更清楚你的目標。 –