-----<useclass.h>------
<cpp.cpp>-------
<cpp2.cpp>--------
~cpp class book { private : // public : book *next; book *first; int situation,selection; book(); ~book(); char book_name[30]; char book_writer[15]; char book_ISBN[10]; void input(); void search(); void borrow(); void restoration(); };------
~cpp #include <iostream> #include "useclass.h" using namespace std; void main() { int number = 0; book b; while(number != 5) { cout << "1. 2. 3. 4. 5. : "; cin >> number; if(number == 5) break; switch(number) { case 1 : b.input(); break; case 2: b.search(); break; case 3: b.borrow(); break; case 4: b.restoration(); break; default : cout<<" ."<<endl; break; } } }------
~cpp #include <iostream> #include <string.h> #include "useclass.h" using namespace std; book :: book(){ situation=0; } book :: ~book(){ } void book :: input() { book * k = new book; cout << " : "; cin >> k->book_name; cout << " : "; cin >> k->book_writer; cout << " ISBN : "; cin >> k->book_ISBN; k->next=first; first=k; } void book :: search(){ char name[30]; char ISBN[10]; cout<<" 과 ISBN . 1. 2.ISBN : "; cin >> selection; if (selection == 1){ cout<<" ?"<<endl; cin>>name; book *find; find = first; while(find->next !=NULL ){ if(strcmp(find->book_name,name)==0) { cout<<" : "<<find->book_name<<endl; cout<<" : "<<find->book_writer<<endl; cout<<"ISBN : "<<find->book_ISBN<<endl; if(find->situation==0){ cout<<" : "<<endl; } else{ cout<<" : "<<endl; } break; } else{ if (find->next == NULL){ cout<<" ."<<endl; break; } else{ find=find->next; } } } } else if (selection==2){ cout<<" ISBN?"<<endl; cin>>ISBN; book *find; find = first; while(find->next !=NULL ){ if(strcmp(find->book_ISBN,ISBN)==0){ cout<<" : "<<find->book_name<<endl; cout<<" : "<<find->book_writer<<endl; cout<<"ISBN : "<<find->book_ISBN<<endl; if(find->situation==0){ cout<<" : "<<endl; } else{ cout<<" : "<<endl; } break; } else{ if (find->next == NULL){ cout<<" ."<<endl; break; } else{ find=find->next; } } } } else{ cout<<" ."<<endl; } } void book :: borrow() { char name_temp[30]; char ISBN_temp[10]; cout << " ISBN .: "; cin >>selection; if (selection == 1){ cout<<" : "; cin >> name_temp; book *lent; lent = first; while(lent->next !=NULL ){ if(strcmp(lent->book_name,name_temp)==0){ lent->situation = 1; break; } else{ lent=lent->next; } } } else if (selection==2){ cout<<" ISBN : "; cin >> ISBN_temp; book *lent; lent = first; while(lent->next !=NULL ){ if(strcmp(lent->book_ISBN,ISBN_temp)==0){ lent->situation = 1; break; } else{ lent=lent->next; } } } else{ cout<<" ."<<endl; } } void book :: restoration() { char restoration_name[30]; char restoration_ISBN[10]; cout<<" ISBN . 1. 2.ISBN: "; cin >> selection; if ( selection == 1){ cout << " : "; cin >> restoration_name; book *restore; restore = first; while(restore->next !=NULL ){ if(strcmp(restore->book_name,restoration_name)==0) { restore->situation = 0; break; } else{ restore=restore->next; } } } else if (selection ==2){ cout << " ISBN : "; cin >> restoration_ISBN; book *restore; restore = first; while(restore->next !=NULL ){ if(strcmp(restore->book_ISBN,restoration_ISBN)==0) { restore->situation = 0; break; } else{ restore=restore->next; } } } else{ cout<<" ."<<endl; } }