C++ a class with an array of structs, without knowing how large an array I need
- by Dominic Bou-Samra
New to C++, and for that matter OO programming.
I have a class with fields like firstname, age, school etc. I need to be able to store other information like for instance, where they have travelled, and what year it was in. I cannot declare another class specifically to hold travelDestination and what year, so I think a struct might be best. This is just an example:
struct travel {
string travelDest;
string year;
};
The issue is people are likely to have travelled different amounts. I was thinking of just having an array of travel structs to hold the data. But how do I create a fixed sized array to hold them, without knowing how big I need it to be?
Perhaps I am going about this the completely wrong way, so any suggestions as to a better way would be appreciated.