You can use iterators and a small for loop to do this. Since you are simply exposing the values ββin a list, you should use const_iterator and not iterator to prevent accidentally modifying the object referenced by the iterator.
Here is an example of how to iterate over a var variable, which is an int 's list
for (list<int>::const_iterator it = var.begin(); it != var.end(); ++it) cout << *it << endl;
source share