[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to improve my question in stackoverflow?



Book.cpp:1:10: fatal error: Set: No existe el fichero o el directorio [closed]

I trying compile an example of a book.

The program use three classes: Book, Customer and Library.

Book.cpp

#include <set>
#include <map>
#include <string>
#include <map>
#include <fstream>
#include <algorithm>
using namespace std;


    #include "book.h"
    #include "customer.h"
    #include "library.h"
    
    // default constructor 
    Book::Book(){
     // Empty
    }
    
    Book::Book(const string& author, const string& title)
        :m_author(author),
        m_title(title){
            // empty
        }
    // methods 
    // They only read and write the author and title of the book 
    void Book::read(ifstream& inStream){
        getline(inStream,m_author);
        getline(inStream,m_title);
    }
    
    void Book::write(ofstream& outStream) const{
        outStream << m_author << endl;
        outStream << m_title << endl;
    }
    
    /* When a customer reserves a book, the pointer to the customer
     * Object is added to the reservation pointer list of the book */
    int Book::reserveBook(Customer* borrowerPtr){
        m_reservationPtrList.push_back(borrowerPtr);
        return m_reservationPtrList.size();
    }
    
    /* When a customer returns a book, we simply set m_borrowerPtr to nullptr*/
    void Book::returnBook(){
        m_borrowerPtr = nullptr;
    }
    
    /* the removeReservation method simply removes the customer
     * pointer from the reservation list*/
    void Book::removeReservation(Customer* customerPtr){
        m_reservationPtrList.remove(customerPtr);
    }
    
    /* the output stream operator writes the title and author, the customer that has borrowed the book, and the customers that have reserved the book */
    ostream& operator << (ostream& outStream, const Book& book){
        outStream << """ << book.m_title << "" by " << book.m_author;
        
        if(book.m_borrowed){
            outStream << endl << " Borrowed by: "
                << Library::s_customerMap[book.m_customerId].name()
                << ".";
        }
    
        if(!book.m_reservationList.empty()){
            outStream << endl << " Reserved by: ";
    
            bool first = true;
            for(int customerId : book.m_reservationList){
                outStream << (first ? "" : ",")
                    << Library::s_customerMap[customerId].name();
                first = false;
            }
    
            outStream << ".";
        }
    
        return outStream;
    
    }

book.h

class Customer;

class Book {
    public:
        Book();
        Book(const string& author,const string& title);

        const string& author() const{return m_author;}
        const string& title() const{return m_title;}

        void read(ifstream& inStream);
        void write(ofstream& outStream) const;

        int reserveBook(Customer* customerPtr);
        void removeReservation(Customer* customerPtr);
        void returnBook();
        
        /*borrowedPtr method returns the address of the customer who has borrowed the book*/
        Customer*& borrowerPtr() {return m_borrowerPtr;}
        const Customer* borrowerPtr() const {return m_borrowerPtr;}

        /* reservationPtrList returns a list of customer pointers instead of integer values*/
        list<Customer*>& reservationPtrList(){
            return m_reservationPtrList;
        }
        
        const list<Customer*> reservationPtrList() const{
            return m_reservationPtrList;
        }

        friend ostream& operator<<(ostream& outStream, const Book& book);

    private: 
        string m_author, m_title;

        Customer* m_borrowerPtr = nullptr;

        /* holds a list of pointers to the customers that have reserved the book*/
        list <Customer*> m_reservationPtrList;
}

When i compile the example with the following command:

g++ -g -Wall  Book.cpp book.h -o book

The result expected is bad.

Book.cpp:1:10: fatal error: Set: No existe el fichero o el directorio
 #include <Set>
          ^~~~~
compilation terminated.

This example was tested from another compiler. The library is not recognized.

The book is C++17 By Example, published by Packt.

--
With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀ 
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀ 

Attachment: Captura de pantalla_2021-09-09_16-26-04.png
Description: PNG image


Reply to: