I need help with the error messages that I keep getting. I'm thinking that there's only one problem and they one problem caused the other problems. I think the one problem is with ifstream.
Script started on Sun Dec 02 18:27:11 2001
strauss.udel.edu% cat library.h
//header file for library class
#ifndef Library_H
#define Library_H
#include "book.h"
#include "card.h"
#include <fstream>
class Library {
private:
static int num_books;
static int num_cards;
Book *books[100];
Card *cards[100];
void printcards();
void printbooks();
void checkout();
void checkin();
public:
Library(ifstream &input);
~Library();
DoCommand(char);
Findbook(int);
Findcard(int);
static int getnum_books;
static int getnum_cards;
};
#endif
strauss.udel.edu% cat lir brary.cc
//member definition for library class
#include "book.h"
#include "card.h"
#include "library.h"
#include <string>
#include <iostream>
using std :: cout;
using std :: cout;
Library :: Library(ifstream &input) {
input.getline(title, 100, "\0");
for(int i = 0; i < 100; i++) {
books[i] = NULL;
while(strcmp(title, $$$) != 0) {
input.getline(author, 100, "\0");
input >> BookID >> status >> CardID;
input.ignore();
books[i] = new Book(title, author, BookID, status, CardID);
num_books++;
input.getline(title, 100, "\0");
}
}
input.getline(name, 100, "\0");
for(int j = 0; j < 100; j++) {
cards[j] = NULL;
while(!input.eof()) {
input.getline(phone, 100, "\0");
input >> CardID >> BookID;
cards[j] = new Card(name, phone, CardID, BookID);
num_cards++;
input.getline(name, 100, "\0");
}
}
Library :: Findbook(Book b) {
while(b[i] != NULL) {
if(BookID == b.BookID)
return BookID;
else
i++;
}
cout >> "Book not found";
}
Library :: Findcard(Card c) {
while(c[i] != eof()) {
if(CardID == c.CardID)
return CardID;
else
j++;
}
cout >> "Card not found";
}
Library :: DoCommand(char c) {
command = c;
if(command = 'B'){
while(books[i] != NULL) {
cout << "Processing book - ";
b[i]->print() ;
cout << endl;
i++;
}
cout << num_books << "books in the library" << endl;
}else if(command = 'C') {
while(cards[j] != NULL)) {
cout << "Processing card - ";
c[j]->print();
cout << endl;
j++;
}
cout << num_cards << "cards in the library" << endl;
}else if(command = 'O') {
cout << "Enter book ID: ";
cin >> BookID;
Findcard(CardID);
cout << "Enter card ID: ";
cin >> CardID;
Findbook(BookID);
if(getBookID() != 0) {
cout << "Sorry. You can't check out a book until"
<< "you return the book that you checked out"
<< "before." << endl;
}else {
if(getstatus() == 0) {
setstatus(1);
setBookID(BookID);
setCardID(CardID);
}else if(getstatus() == 1) {
cout << "Sorry, but the has already been"
<< "checked out."<< endl;
}else {
cout << "Book is at the bindery."<< endl;
}
}else if(command = 'W') {
cout << "Enter book ID: ";
cin >> BookID;
Findbook(BookID);
cout << "Enter card ID: ";
cin >> CardID;
Findcard(CardID);
if(getBookID() == 0) {
cout << "You do not have any books checked out" << endl;
}else {
if(getstatus() == 1){
setstatus(0);
setBookID(BookID);
}
}
}
strauss.udel.edu% make
CC -c library.cc
"library.h", line 20: Error: ifstream is not defined.
"library.cc", line 12: Error: ifstream is not defined.
"library.cc", line 13: Error: input is not defined.
"library.cc", line 13: Error: title is not defined.
"library.cc", line 13: Error: Badly formed expression.
"library.cc", line 17: Error: title is not defined.
"library.cc", line 17: Error: Expected an expression.
"library.cc", line 18: Error: input is not defined.
"library.cc", line 18: Error: author is not defined.
"library.cc", line 18: Error: Badly formed expression.
"library.cc", line 19: Error: input is not defined.
"library.cc", line 19: Error: BookID is not defined.
"library.cc", line 19: Error: status is not defined.
"library.cc", line 19: Error: CardID is not defined.
"library.cc", line 20: Error: input is not defined.
"library.cc", line 20: Error: Badly formed expression.
"library.cc", line 21: Error: title is not defined.
"library.cc", line 21: Error: author is not defined.
"library.cc", line 21: Error: BookID is not defined.
"library.cc", line 21: Error: status is not defined.
"library.cc", line 21: Error: CardID is not defined.
"library.cc", line 23: Error: input is not defined.
"library.cc", line 23: Error: title is not defined.
"library.cc", line 23: Error: Badly formed expression.
"library.cc", line 26: Error: input is not defined.
Compilation aborted, too many Error messages.
*** Error code 1
make: Fatal error: Command failed for target `library.o'
strauss.udel.edu% exit
strauss.udel.edu%
script done on Sun Dec 02 18:27:30 2001