DISCLAIMER Good day, I am a novice programmer so please don't judge me if I have any mistakes that may be obvious or not.
I have a code that looks like this.
class Book{
public:
string author;
string title;
int yearPub;
}
int main(){
Book books[999];
}
However, I don't know how to predefine a certain amount of titles and authors like how they are defined in other variable types like this:
string author[99] = {"asdf","asf","asdff"};
int x[] = {9,10,19};
I tried initializing a constructor and did this:
class Book{
public:
...
Book(string AUTH, string TTL, int YROP){
author = AUTH;
title = TTL;
yearPub = YROP
}
...
}
int main(){
Book books[999] = Book({"author1","author2"},{"title1","title2},{2022,2022});
return 0;
}
But it doesn't work. Do you know any way to do this?