0

C++ database program consisting of class called books. Can someone please help tell where the error is in this code

#include <iostream> #include <conio.h> #include <string> using namespace std; const int T=10; class Book{ private:string Publisher,Author,Title; int Acc_no;int Copies; float Price; public:void getATB(){ cout<<"Enter Book Title\n"; getline(cin,Title); cout<<"Enter the Book Author\n"; getline(cin,Author); cout<<"Enter the Book Publisher\n"; getline(cin,Publisher);} void getACP(){cout<<"Enter Book Account number\n"; cin>>Acc_no; cout<<"Enter Number of Book copies\n"; cin>>Copies; cout<<"Enter Price of the Book\n"; cin>>Price;} void showbooks()const { cout<<"\nTITLE:"<<Title<<"\nAUTHOR:"<<Author<<"\nPUBLISHER:"<<Publisher<<"\nBOOK ACCOUNT NO:"<<Acc_no<<"COPIES:"<< Copies<<"PRICE"<<Price; }; int main(){ int i; Book b[T];{ for(i=0;i<[T];i++) { b[i].getATB(); } for(i=0;i<T;i++){ b[i].getACP();} for(i=0;i<T;i++){ b[i].showbooks(); } } } };

27th Mar 2022, 4:56 AM
Kelvin Kemboi
1 Antwort
+ 1
1. No need for the last }; 2. Solo learn doesnt recoginze conio.h library 3. In main first for loop it, should check i < T not i < [T] 4. I reccomend implemetning the class without so much cin and cout Instead using helper/ friend functions
27th Mar 2022, 5:40 AM
Raul Ramirez
Raul Ramirez - avatar