My ABC is:
My derived class is:Code://holding.h #ifndef _HOLDING_H #define _HOLDING_H #include <stdlib.h> #include <iostream> #include <fstream> using namespace std; class Holding{ protected: char *title; int titleLength; int callNumber; public: Holding(char *, int); Holding(const Holding &); virtual ~Holding(); virtual void print(ostream &) = 0; }; #endif // holding.cpp #include "holding.h" Holding::Holding(char *tempTitle, int tempCallNumber){ titleLength = strlen(tempTitle); title = new char[titleLength + 1]; strcpy(title, tempTitle); title[titleLength] = '\0'; callNumber = tempCallNumber; } Holding::Holding(const Holding &temp){ titleLength = temp.titleLength; title = new char[titleLength + 1]; strcpy(title, temp.title); title[titleLength] = '\0'; callNumber = temp.callNumber; } Holding::~Holding(){ delete [] title; }
My main is:Code:// Book.h #ifndef _BOOK_H #define _BOOK_H #include <stdlib.h> #include <iostream> #include <fstream> #include "holding.h" class Book : Holding { protected: char * author; int authorLength; public: Book(char *, char *, int); Book(const Book &); virtual ~Book(); virtual void print(ostream &); }; #endif // Book.cpp #include "book.h" Book::Book(char *tempAuthor, char * title, int callNumber) : Holding(title, callNumber) { authorLength = strlen(tempAuthor); author = new char[authorLength + 1]; strcpy(author, tempAuthor); author[authorLength] = '\0'; } Book::Book(const Book &temp) : Holding(temp) { authorLength = temp.authorLength; author = new char[authorLength + 1]; strcpy(author, temp.author); author[authorLength] = '\0'; } Book::~Book(){ delete [] author; } void Book::print(ostream &out){ cout << "Book: " << author << " " << '\"' << title << '\"' << " " << callNumber << endl; out << "Book: " << author << " " << '\"' << title << '\"' << " " << callNumber << endl; }
In the end I'm getting this error:Code:// library.h #ifndef _LIBRARY_H #define _LIBRARY_H #include <stdlib.h> #include <iostream> #include <fstream> #include "holding.h" #include "holding.cpp" #include "book.h" #include "book.cpp" #endif // library.cpp #include <iostream> #include <fstream> #include <stdlib.h> #include "library.h" ofstream csis; int main(){ csis.open("csis.dat"); char type; char format; char callNumber[100]; char author[100]; char title[100]; Book *book; Holding *Holdings[5]; book = new Book("Jeremiah", "Loo", 125); Holdings[0] = book; }
I don't know why it's having trouble access it. I believe I clearly derived Book from Holding. Thanks for any suggestions or help.Code:'Holding' is an inaccessible base of 'Book'



LinkBack URL
About LinkBacks



CornedBee