Hello,
I am wondering how do we initialize a vector (or even an array) of pointers when the objects that will eventually be pointed to don't exist yet? I've been searching the internet for a while, but most examples assume that the objects already exist.
I hope this won't be too confusing but to further illustrate what I'm trying to do. Let's say that I want to simulate the passengers on a plane using: vector<Person*> passengers. When I create an instance of the Airplane class that passengers will be a member of, passengers should be empty. Only when I use a method like sellTicket(Person *personPtr) or maybe boardPassenger(Person *personPtr) will a pointer be added to the vector. So how can I initialize passengers so that if I, for example, run a method that lists all the Person objects pointed to by passengers prior to actually adding any pointers I won't crash the program because I'd have some value to evaluate.
Does that make sense to anyone? I hope so =)