Greetings,
i've a class C which contains a list of pointers to a class A.
That list must only be modified by C methods, hence it's private.
Still i'd need to let the user loop through the A items contained in that list.
Is there a way to make the list loop-able but not modifiable which isn't adding a custom iterator to my class C?
As someone else said, by returning const reference to that collection. The collection doesn't need to be const, but you can return a const reference to it so that code outside the class cannot modify the collection.