sqarohu icik me mire se nuk po te kuptoj!!!!
gjeni gabimet ne kete ushtrim
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Book{
public:
//Book(int sz = 50);
//~Book();
void setDay(ifstream fn);
void setMonth(ifstream fn);
void setYear(ifstream fn);
void setNpg(ifstream fn);
void setIsbn(ifstream fn);
void setCateg(ifstream fn);
void setAid(ifstream fn);
void setTitle(ifstream fn);
int getDay() const;
int getMonth() const;
int getYear() const;
int getNpg() const;
int getIsbn() const;
string getCateg() const;
int getAid() const;
string getTitle() const;
private:
int d; //day
int m; //month
int y; //year
int npg; //number of pages
int isbn; //ISBN 13 digits number
string categ; //category of the title
int aid; //author ID
string title; //title of the book
int sz;
//Book *data;
};
class Author{
public:
//Author(int sz = 50);
//~Author();
void setFname(ifstream fn2);
void setLname(ifstream fn2);
void setAid(ifstream fn2);
string getFname() const;
string getLname() const;
int getAid() const;
private:
string fname; //the first name of the author
string lname; //the last name of the author
int aid; //author id
int sz;
//Author *data;
};
int main(){
char choice;
do{
ifstream fn1;
ifstream fn2;
string ch;
string filename1 = "book.txt";
string filename2 = "author.dat";
cout<<"Welcome!!!"<<endl;
cout<<"Please enter a filename: ";
cin>>ch;
if(ch == filename1){
fn1.open(filename1.c_str());
cout<<"File "<<filename1<<" succesfully opened!!!"<<endl;
Book::setNpg(fn1);
Book::setIsbn(fn1);
Book::setCateg(fn1);
Book::setDay(fn1);
Book::setMonth(fn1);
Book::setYear(fn1);
Book::setAid(fn1);
Book::setTitle(fn1);
cout<<"The file: "<<endl;
cout<<endl;
cout<< Book::getAid();
fn1.close();
}
else if(ch == filename2){
fn2.open(filename2.c_str());
cout<<"File "<<filename2<<" succesfully opened!!!"<<endl;
Author::setFname(fn2);
Author::setLname(fn2);
Author::setAid(fn2);
}
else
cout<<"Please enter the exact filename if you know it!!!"<<endl;
cout<<"Enter [Y/y] to enter the filename again or [N/n] to exit the program now: ";
cin>>choice;
}while(choice == 'Y' || choice == 'y');
return 0;
}//end of main
/*
Book::Book(int sz){
if(sz == 0)
data = NULL;
else
data = new Book[sz];
}//end of constructor
Book::~Book(){
if(sz == 1)
delete data;
else if(sz > 1)
delete [] data;
}//end of destructor
*/
void Book::setNpg(ifstream fn){
while(!'\0'){
int npg[50];
for(int i = 0; i < sz; i++)
fn>>npg[i];
}
}//end of setNpg;
void Book::setIsbn(ifstream fn){
while(!'\0'){
int isbn[50];
for(int i = 0; i < sz; i++)
fn>>isbn[i];
}
}
void Book::setCateg(ifstream fn){
while(!'\0'){
for(int i = 0; i < sz; i++)
fn>>categ[i];
}
}
void Book::setDay(ifstream fn){
while(!'\0'){
int d[50];
for(int i = 0; i < sz; i++)
fn>>d[i];
}
}
void Book::setMonth(ifstream fn){
while(!'\0'){
int m[50];
for(int i = 0; i < sz; i++)
fn>>m[i];
}
}
void Book::setYear(ifstream fn){
while(!'\0'){
int y[50];
for(int i = 0; i < sz; i++)
fn>>y[i];
}
}
void Book::setAid(ifstream fn){
while(!'\0'){
int aid[50];
for(int i = 0; i < sz; i++)
fn>>aid[i];
}
}
void Book::setTitle(ifstream fn){
while(!'\0'){
for(int i = 0; i < sz; i++)
fn>>title[i];
}
};
int Book::getAid() const{return aid;}
string Book::getCateg() const{return categ;}
int Book::getDay() const{return d;}
int Book::getMonth() const{return m;}
int Book::getYear() const{return y;}
string Book::getTitle() const{return title;}
int Book::getIsbn()const{return isbn;}
int Book::getNpg()const{return npg;}
/*
Author::Author(int sz){
if(sz == 0)
data = NULL;
else
data = new Author[sz];
}//author class constructor
Author::~Author(){
if(sz == 1)
delete data;
else if(sz > 1)
delete [] data;
}//author class destructor
*/
void Author::setAid(ifstream fn2){
while(!'\0'){
int aid[50];
for(int i = 0; i < sz; i++)
fn2>>aid[i];
}
}
void Author::setFname(ifstream fn2){
while(!'\0'){
for (int i = 0; i< sz; i++)
fn2>>fname[i];
}
}
void Author::setLname(ifstream fn2){
while(!'\0'){
for (int i = 0; i< sz; i++)
fn2>>lname[i];
}
}
int Author::getAid() const{return aid;}
string Author::getFname() const{return fname;}
string Author::getLname() const{return lname;}
____________