0
I am creating a Bookshop and at the time of registering a new book, the user must say the amount of books that will be registered, but I am not able to do it, I can only create a preset amount of object.
Here in the code I tried to create an array, but it requires that it be a constant prevented the user from defining the amount that will be created.
void AddNewBook() {
system("CLS");
int amountBooks;
std::cout << "How many books will be added? ";
std::cin >> amountBooks;
if (amountBooks < 1) {
Error("No book will be added.");
Options(Choice());
}
else {
Book books[amountBooks];
}
}
I wonder if there is a way to create the amount of objects that the user needs dynamically?
I beg your pardon if my doubt is not clear.
I think this can help you: https://stackoverflow.com/questions/44678457/dynamic-objects-in-c/44678941#:~:text=If%20you%20write%20A%20*%20a,A%20and%20not%20an%20array. and also: https://answall.com/questions/87980/forms
– Maicon Herverton