mercredi 3 juin 2020

Random object generator c++

I've been working on a project that is supposed to recreate the tripulation of a plane. I couldn't figure out how to program a key feature that I want it to have.

How can I generate a set number of objects that pick their parameters from a predefined list? For example, suppose we have the class "Passenger" which takes the parameters Name, Age, Nationality and phoneNumber. I need the program to generate, let's say 10 objects of the class passenger and take their attributes randomly from an array of 20 preset names. I know I could define 10 objects by myself, but what happens if I want to generate like 100 of them? Is there a way to do it?

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire