Question: [C++ Code] Reading from a file to an object, then storing it in an array So I have a class, Book, as shown below. My
[C++ Code] Reading from a file to an object, then storing it in an array
So I have a class, Book, as shown below. My question is how do I read from a file called input.data to create a Book object from each line (see example input.dat below)? As each Book object is created, how do I store it in an array of the type Book.
![[C++ Code] Reading from a file to an object, then storing it](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66e2ea517afc7_15366e2ea5111ea9.jpg)
Example input.dat
000001, Bjarne Stroustrup, The C++ Programming Language, 4, 2013, 0321563840
000002, Stephen Colbert, Stephen Colbert's Midnight Confessions, 1, 2017, 1501169009
000003, Tom Clancy, The Hunt for Red October, 2, 1984, 0425240339
000004, Gregory Dudek, Computational Principles of Mobile Robotics, 2, 2010, 0521692121
class Book t public: Book (); Book(string id, string auth, string tit, int ed, int yr, string isbn); private: string book_id; string author; string title; int edition; int pub_year; string ISBN
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
