Compiled in Visual Studio 2017.
#include "stdafx.h" #include<stdio.h> #include<cstdio> #include<iostream> #define size 50 using namespace std; class card { char title[size]; char author[size]; int num_book; public: void store(); void show(); }; void card::store() { cout << "Enter Title: "; std::cin.getline(title,size); //cin >> title; cout << "Enter Author: "; std::cin.getline(author,size); //cin >> author; cout << "Enter number of copies: "; cin >> num_book; getchar(); // if char std::cin.getline(num_book, 3); } void card::show() { std::cout << "\nTitle: " << title << " \nAuthor: " << author << "\nCopies: " << num_book; } // ENTRY POINT - GOVERNOR int main() { int choice; card b1, b2; cout << "{{{ Library Management System }}}\n\n"; // INPUT cout << "\nStore book-1 information\n"; b1.store(); cout << "\nStore book-2 information\n"; b2.store(); // OUTPUT cout << "\n\nInformation of book-1"; b1.show(); cout << "\n\nInformation of book-2"; b2.show(); cin.get(); }
Screenshot