Sharing is caring!

C++ project: Library Management System

Create a library management system that allows library users to manage books. The system should allow users to add new books, search for books, borrow and return books, and view the available books.


  1. The system should have a user interface where users can interact with the program.
  2. Users should be able to add new books to the library by providing details such as the book title, author, ISBN, and publication year.
  3. Users should be able to search for books in the library based on various criteria such as title, author, or ISBN.
  4. The system should keep track of the availability of each book, indicating whether it is currently borrowed or available for borrowing.
  5. Users should be able to borrow books by providing their library card number or ID and the ISBN of the book.
  6. Users should be able to return books by providing the ISBN of the book they want to return.
  7. The system should maintain a list of borrowed books and provide the ability to display this list.
  8. Users should be able to view the details of a specific book, including its title, author, ISBN, publication year, and availability.


#include <iostream>
#include <vector>
#include <string>

class Book {
    std::string title;
    std::string author;
    std::string isbn;
    int publicationYear;
    bool isAvailable;

    Book(const std::string& title, const std::string& author, const std::string& isbn, int publicationYear)
        : title(title), author(author), isbn(isbn), publicationYear(publicationYear), isAvailable(true) {}

    std::string getTitle() const {
        return title;

    std::string getAuthor() const {
        return author;

    std::string getISBN() const {
        return isbn;

    int getPublicationYear() const {
        return publicationYear;

    bool getAvailability() const {
        return isAvailable;

    void setAvailability(bool availability) {
        isAvailable = availability;

class Library {
    std::vector<Book> books;

    void addBook(const Book& book) {

    void displayBooks() const {
        std::cout << "Library Books:" << std::endl;
        for (const auto& book : books) {
            std::cout << "Title: " << book.getTitle() << std::endl;
            std::cout << "Author: " << book.getAuthor() << std::endl;
            std::cout << "ISBN: " << book.getISBN() << std::endl;
            std::cout << "Publication Year: " << book.getPublicationYear() << std::endl;
            std::cout << "Availability: " << (book.getAvailability() ? "Available" : "Borrowed") << std::endl;
            std::cout << "---------------------" << std::endl;

    Book* findBookByISBN(const std::string& isbn) {
        for (auto& book : books) {
            if (book.getISBN() == isbn) {
                return &book;
        return nullptr;
int main() {
    Library library;

    Book book1("The Great Gatsby", "F. Scott Fitzgerald", "9780743273565", 1925);
    Book book2("To Kill a Mockingbird", "Harper Lee", "9780061120084", 1960);
    Book book3("1984", "George Orwell", "9780451524935", 1949);



    std::string isbn;
    std::cout << "Enter the ISBN of the book you want to borrow: ";
    std::cin >> isbn;

    Book* foundBook = library.findBookByISBN(isbn);
    if (foundBook != nullptr) {
        if (foundBook->getAvailability()) {
            std::cout << "Book borrowed successfully!" << std::endl;
        } else {
            std::cout << "Book is not available for borrowing." << std::endl;
    } else {
        std::cout << "Book not found in the library." << std::endl;

    return 0;

Optional Enhancements:

  1. Implement a feature to allow users to reserve books that are currently unavailable.
  2. Add a feature to generate reports, such as the most borrowed books or the books with the highest ratings.
  3. Implement a user authentication system to differentiate between librarians and regular users, allowing librarians to perform administrative tasks such as adding or removing books.

Categories: C++


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *