Hi, this program is supposed to get data from an input file, have the user add new data, then output the new data in an output file. There are also supposed to be inheritance classes for the different titles. The 2 derived classes should be a fiction one and a non-fiction one. I m quite a begginer at classes so i'm not sure how to carry on! Any help would be great, thanks!


------------------------header file------------------------------------------
#ifndef __BOOK_H__
#define __BOOK_H__

class Book
{
private:

char date[11];
int booknum;
char catnum[11];
char title[31];
char author[31];
char type;

public:
//constructor
Book();
//destructor
~Book();

//instance methods
void readdate(); //function to get data from input file
//void adddata(); //function to add new data
void outputdate(); //function to output data into output file


};

#endif

-------------------------------------------------------------------------------

-----------main.cpp---------------------------------------------------------

#include<iostream.h>
#include<stdlib.h>
#include<fstream.h>
#include<cstring>
#include"Book.h"

using namespace std;

int main()
{

return 0;

}
---------------------------------------------------------------------------------
----------implementation file-------------------------------------------------

#include<cstring>
#include"Book.h"

Book::Book()

Book::~Book()

void Book::readdate()
{
ifstream inFile;

inFile.open("BOOKS.dat");

inFile>>date;

cout<<date<<endl;

}

void Book::outputdate()
{
ofstream outFile;

outFile.open("NEWBOOKS.dat");

outFile<<date<<endl;


}

-------------------------------------------------------------------------

it looks OK so far - Although I would suggest seperating your file input function out away from your book class, unless you want every single book object to hold exactly the same information (When you close a file and re-open it, the file reads from the start of the file again)

If you're satisfied with the book class at the moment, then your next step is probably to write your Fiction and Nonfiction classes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.