#include <iostream>
#include <vector>
#include <string>
class Book {
private:
std::string title;
std::string author;
int year;
public:
Book(std::string t, std::string a, int y) : title(t), author(a), year(y) {}
std::string getTitle() const {
return title;
}
std::string getAuthor() const {
return author;
}
int getYear() const {
return year;
}
friend std::ostream& operator<<(std::ostream& os, const Book& book) {
os << book.title << " by " << book.author << " (" << book.year << ")";
return os;
}
};
class Library {
private:
std::vector<Book> books;
public:
void addBook(const Book& book) {
books.push_back(book);
}
void displayBooks() const {
for (const Book& book : books) {
std::cout << book << std::endl;
}
}
}