[c++] How to iterate through a list of objects in C++