c++

I hAve asked this question for several days. I am struggling with this program. There is a input file which is of .txt. It contains list of about fifty books in the format: catalogue_number, author_last_name, author_first_name_, book_title, genre, availabilty.
**Catalogue number's are four characters like "A145"
The program needs to store the objects (class book catalogue_number, author_last_name, author_first_name_, book_title, genre, availabilty) in an array, sort author_last_name, and output as a .txt file.

I can't use vector, command line or anything like that. PLEASE!! PLEASE!! PLEASE!! I have been trying for days to make my program work the way it's supposed to work.

ok I trying to output what's in the input file (.txt) to an output file (.txt):
these are the errors:
book.h:
line 14:expected ')' before "A"
line 15: expected unqualified-id before '{' token

main.cpp:
line 22: 'cout' undeclared [first use this function]
line 34: 'string' undeclared [first use this function]
expected ';' before "A"
line 35: 'A' undeclared [first use this function]
'B' undeclared [first use this function]
'C' undeclared [first use this function]
'D' undeclared [first use this function]
'E' undeclared [first use this function]
'F' undeclared [first use this function]
line 36: no match for 'operator+' in 'book+i'
line 39: 'endl' undeclared [first use this function]
line 40: 'N' undeclared [first use this fucntion]
line 41: no match for 'operator+' in 'book+i'
'getCatalogue_Number' undeclared [first use this function]
'getAuthor_Last_Name' undeclared [first use this function]
'getAuthor_First_Name' undeclared [first use this function]
'getBook_Title' undeclared [first use this function]
'getGenre' undeclared [first use this function]
'get Availability' undeclared [first use this function]

Last edited on
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

#include "book.h"
#include "book.cpp"
using std::ifstream;
using std::ofstream;

int main()
{
    Book book;
    ifstream inStream;
    ofstream outStream;

    
    inStream.open("library_holdings.txt");
    if(inStream.fail())
    {
       cout <<"Input file opening failed.\n";
       exit(1);
    }
    outStream.open("computational_task_1.txt");
    if(outStream.fail())
    {
       cout <<"Output file opening failed.\n";
       exit(1);
    }
    int i=0;
    while(!inStream.eof())
    {
     string A,B,C,D,E,F;
     inStream>>A>>B>>C>>D>>E>>F;
     *(book+i)=new Book(A,B,C,D,E,F);
     i++;
      } 
       cout<<"Reading from file is over"<<endl;
      for(i=0;i<N;i++)
      cout<<book[i]<<getCatalogue_Number()<<getAuthor_Last_Name<<getAuthor_First_Name<<getBook_Title<<getGenre<<getAvailability;
     
                                         
    
    inStream.close();
   outStream.close();
   system ("PAUSE");
   return 0;
}
book.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _BOOK_H_
#define _BOOK_H_

class Book
{
public:
    void output();
    std:: string getCatalogue_Number() const;
    std:: string getAuthor_Last_Name() const;
    std:: string getAuthor_First_Name() const;
    std:: string getBook_Title () const;
    std:: string getGenre () const;
    std:: string getAvailability () const;
    Book(string A, string B, string C, string D, string E, string F);
    {
       catalogue_number=A;
       author_last_name=B;
       author_first_name=C;
       book_title=D;
       genre=E;
       availability=F;
    } 

private:
    std:: string catalogue_number;
    std:: string author_last_name;
    std:: string author_first_name;
    std:: string book_title;
    std:: string genre;
    std:: string availability;
};

#endif 
book.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdlib.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include "book.h"


    
std:: string Book::getCatalogue_Number() const{
    return catalogue_number;
}

std:: string Book::getAuthor_Last_Name() const{
    return author_last_name;
}

std:: string Book::getAuthor_First_Name() const{
    return author_first_name;
}

std:: string Book::getBook_Title() const{
    return book_title;
}

std:: string Book::getGenre() const{
    return genre;
}

std:: string Book::getAvailability() const{
    return availability;
}
You are being helped here: http://cplusplus.com/forum/general/68753/

PLEEEEEEEEEAASE, stop jumping threads! It is confusing and wastes the time of the people who are trying to help you.
but i changed the program
Topic archived. No new replies allowed.