Question: Please help me figure out whats wrong with the program I'm writing. Its almost done but there are a few small bugs I cannot work

Please help me figure out whats wrong with the program I'm writing. Its almost done but there are a few small bugs I cannot work out. Thank you for the help.

Problem:

Your design and C++ code should contain a base class and a derived class in which the derived class has inheritance of the base class. Design and implement in C++ a base class for the concept BOOK to represent book(s) and a derived class for the concept LIBRARY CARD that inherits the class definition BOOK in which LIBRARY CARD is a typical library card used by a library to provide a record of a book in a library. For both class definitions (BOOK and LIBRARY CARD) make sure to define class members (methods and data) as pubic or private or protected. Make sure to have a constructor and destructor for each class. Your program will use a constructor to create an instance of the class object LIBRARY CARD that in turn creates with a constructor an instance of the inherited class object BOOK. Each object, LIBRARY CARD and BOOK, should be instantiated with data by the respective constructors. Once you have created an instance of a library card and book, your program should output all the data for the instance of a LIBRARY CARD object with all the data for the inherited BOOK object.

Such data could include:

For BOOK ---- title of book, author name, total number of pages,

For LIBRARY CARD ---- book code number, book checked out/in status code,

This is what I have so far and its throwing these errors:

Please help me figure out whats wrong with the program I'm writing.

CODE:

#include

#include

using namespace std;

class book

{

public:

book(char *, char *, int, float);

~book(void);

void show_book(void);

int change_pages(float);

int book_id(void);

protected:

char title[64];

private:

char author[64];

int book_id;

float pages;

};

book::book(char *title, char *author, int book_id, float pages)

{

cout

cout

strcpy_s(book::title, title);

strcpy_s(book::author, author);

book::book_id = book_id;

if (pages

{

book::pages = pages;

}

else

{

book::pages = 0.0;

}

}

book::~book(void)

{

cout

cout

}

void book::show_book(void)

{

cout

cout

cout

cout

cout

}

int book::change_pages(float new_pages)

{

if (new_pages

{

pages = new_pages;

return(0);

}

else

{

return(-1);

}

}

int book::book_id(void)

{

return(book_id);

}

class libraryCard : public book

{

public:

libraryCard(char *, char *, int, float, char *, float, int);

~libraryCard(void);

void show_libraryCard(void);

private:

char company_car[64];

float checkedIn_bonus;

int checkedOut_options;

};

libraryCard::libraryCard(char *title, char *author, int book_id, float pages, char *company_car, float bonus, int checkedOut_options) : book(title, author, book_id, pages)

{

cout

cout

strcpy_s(libraryCard::company_car, company_car);

libraryCard::checkedIn_bonus = bonus;

libraryCard::checkedOut_options = checkedOut_options;

}

libraryCard::~libraryCard(void)

{

cout

}

void libraryCard::show_libraryCard(void)

{

show_book();

cout

cout

cout

}

int main(void)

{

book worker((char *) "Ryan Newbury", (char *) "Librarian", 101, 10101.0);

libraryCard boss((char *) "Jane Doe", (char *) "Student", 102, 40101.0, (char *) "Out", 5000, 1000);

worker.show_book();

boss.show_libraryCard();

getchar();

return 0;

}

declaration is incompatible with "int book: book id" (declared at line 17 (x c2365 book book id': redefinition; previous definition was 'member function' (x C2659 '-1: function as left operand (x C3867 book book id': non-standard syntax use '&' to create a pointer to member (x C3867 book book id': non-standard syntax use '&' to create a pointer to member X C2440 eturn': cannot convert from "int thiscall book:* VOI to 'int' Project Project Project Project Project Project Source.cpp 66 source cpp 17 source cpp 27 source cpp 49 source cpp 68 source cpp 68

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!