컴파일후 오류창이 뜨는거는 왜그런거죠??
청식
#include iostream
using namespace std;
struct Bookst{
int BookID;
int RenterID;
Bookst *ptr;
};
class Bookll{
Bookst *BookHead;
Bookst *BookTail;
public:
void Book_init();
void Book_add();
void Book_del();
void Book_show();
void Book_rent(int, int);
void Book_return(int, int);
Bookst * Booklocationof(int y);
Bookst * Booklocationbefore (Bookst * y);
};
struct Memberst{
int MemberID;
int BorrowedBookID;
Memberst *next;
};
class Memberll{
Memberst *MemberHead;
Memberst *MemberTail;
public:
void Member_init();
void Member_add();
void Member_del();
void Member_show();
void Book_rent(int,int);
void Book_return(int,int);
Memberst *Memberlocationof(int y);
Memberst *Memberlocationbefore(Memberst * y);
};
Bookll bll;
Memberll mll;void Bookll::Book_init(){
BookHead = new Bookst;
BookHead - BookID = 0;
BookHead - RenterID = 0;
BookHead - ptr=0;
BookTail = BookHead;
}
void Bookll::Book_add(){
int x;
cout 책 번호를 입력하세요.endl;
cin x;
Bookst * p;
p = new Bookst;
p-BookID = x;
p-RenterID =0;
BookTail-ptr=p;
p-ptr=0;
BookTail=p;
}
Bookst *Bookll::Booklocationof(int y){
Bookst *p;
for(p=BookHead-ptr;p!=0;p=p-ptr){
if(y==p-BookID)
return p;
}
return 0;
}
Bookst * Bookll::Booklocationbefore(Bookst * y){
Bookst *p;
for(p=BookHead-ptr;p!=0;p=p-ptr){
if (p-ptr == y)
return p;
}
return 0;
}void Bookll::Book_del(){
int x;
Bookst *q;
cout삭제할 책 번호를 입력하세요.endl;
cinx;
q=bll.Booklocationof(x);if (q==0){
cout no such bookendl;
return;
}Bookst *p;
p=bll.Booklocationbefore(q);
p-ptr=q-ptr;
delete q;
}
void Bookll::Book_show(){
Bookst *p;
for(p=BookHead-ptr;p!=0;p=p-ptr){
coutBook id: p-BookID Renter : p-RenterIDendl;
}
}
void Bookll::Book_rent(int x,int y){
Bookst *p;
p = Booklocationof(x);
if (p==0){
cout다시 입력해주세요.endl;
return;
}
p-RenterID = y;
}
void Memberll::Book_rent(int x,int y){
Memberst *p;
p=Memberlocationof(y);
if (p==0){
cout다시 입력해주세요.endl;
return;
}
p-BorrowedBookID=x;
}
void Bookll::Book_return(int x,int y){
Bookst *p;
p = Booklocationof(x);
if (p==0){
cout다시 입력해주세요.endl;
return;
}
p-RenterID = 0;
}
void Memberll::Book_return(int x,int y){
Memberst *p;
p=Memberlocationof(y);
if (p==0){
cout다시 입력해주세요.endl;
return;
}
p-BorrowedBookID=0;
}
void Memberll::Member_init(){
MemberHead = new Memberst;
MemberHead - MemberID=0;
MemberHead - BorrowedBookID=0;
MemberHead - next=0;
MemberTail = MemberHead;
}
void Memberll::Member_add(){
int x;
cout 추가할 ID를 입력하세요.endl;
cin x;
Memberst * p;
p = new Memberst;
p-MemberID = x;
p-BorrowedBookID = 0;
MemberTail-next=p;
p-next=0;
MemberTail=p;
}
Memberst * Memberll::Memberlocationof(int y){
Memberst *p;
for(p=MemberHead-next;p!=0;p=p-next){
if (y==p-MemberID)
return p;
}
return 0;
}
Memberst * Memberll::Memberlocationbefore(Memberst * y){
Memberst *p;
for(p=MemberHead-next;p!=0;p=p-next){
if (p-next == y)
return p;
}
return 0;
}
void Memberll::Member_del(){
int x;Bint x;
Memberst *q;
cout 삭제할 멤버 ID를 입력하세요.endl;
cin x;
q=mll.Memberlocationof(x);
if (q==0){
cout no such Memberendl;
return;
}Memberst *p;
p=mll.Memberlocationbefore(q);
p-next=q-next;
delete q;
}
void Memberll::Member_show(){
Memberst *p;
for (p=MemberHead-next;p!=0;p=p-next){
coutMemberID:p-MemberIDBorrowed book:p-BorrowedBookIDendl;
}
}
void BookLL_rent(){
int x,y;
cout대여하실 책 번호를 입력하세요:endl;
cinx;
cout대여하실 분의 멤버ID를 입력하세요:endl;
ciny;
bll.Book_rent(x,y);
mll.Book_rent(x,y);
}
void BookLL_return(){
int x, y;
cout반납하실 책 번호를 입력하세요:endl;
cinx;
cout반납하실 분의 멤버ID를 입력하세요:endl;
ciny;
bll.Book_return(x,y);
mll.Book_return(x,y);
}
void main(){
bll.Book_init();
mll.Member_init();
int sel;
for(;;){
cout Book_add(1), Book_del(2), Book_show(3), endl;
cout Member_add(4), Member_del(5), Member_show(6), endl;
cout Book_rent(7), Book_return(8), Quit(9) endl;
cin sel;
if (sel==9) break;
switch (sel){
case 1:
bll.Book_add();
break;
case 2:
bll.Book_del();
break;
case 3:
bll.Book_show();
break;
case 4:
mll.Member_add();
break;
case 5:
mll.Member_del();
break;
case 6:
mll.Member_show();
break;
case 7:
BookLL_rent();
break;
case 8:
BookLL_return();
break;
}
}
}제가 만든 프로그램인데요.
오류도 수정도 다했고 잘된거 같은데 컴파일 하고나서 실행하면 작동은 됩니다.
그런데 북델리트와 멤버델리트만 쓰면 오류창이 뜨면서 꺼지네요.....
이건 왜 그런거죠???
제발 알려주세요.