vendredi 9 avril 2021

is it possible to combine 2 objects of class into one in c++?

I am reading file that contains

Johh, 13, soccer, cricket
Mitchell, 14, cricket
Michael, 13, football, cricket, soccer
(all three in separate lines starting from names)

I have created class with objects called name, age and favourite sport. is it possible in C++ to combine stuff after age (which are favourite sports) into one object rather then having to write favourite sport1, favourite sport2 etc. Example for John it can be student.getname() = john, student.getAge() = 13 and student.getFavSport = soccer,cricket. etc

really stuck at this part, have never been taught, any help would be appreciated Thank you

Aucun commentaire:

Enregistrer un commentaire