I'm a beginner in programming and I'm learning the C++ programming language using the book : Programming principles and practice using C++. Today I'm here because I need help with solving a technical problem. In chapter 9 I have to write this program that implements a Book class such as we can imagine it as a part of a library software. Our book class will have 4 members : an ISBN (represented with the form n-n-n-x where n is an integer and x is a letter or digit), the name of the author, the name of the book, the copyright date.
I just started using classes so I'm still learning what kind of consideration a programmer should do while writing the code, for this class I don't think we can provide any default constructor because there is no default value to give to a book. So, deciding to have 4 arguments for the Book constructor we would have somenthing like this :
class Book {
public:
Book(string, string, string, Date);
private:
string isbn;
string author;
string title;
Date copyright_date; // I defined the Date class in a previous exercise
};
After writing this brief skecth of the Book class I think now that the constructor for the book class can be a problem, this is because it takes 4 arguments that can make the initialization list really long :
Book b1{ "1,2,3,h", "Stroustrup", "Programming principles and practice using C++", {2015,Month::jan, 1} };
Do you think this initialization of a Book is too long ? what if I would like to create a vector of Books ? how would you solve this problem ? Please remember that I am not an expert so I still can't understand everything about classes and their design, this is just a question to try to improve my skills and to get a better idea about classes.