That’s something I’ve been meaning to add, actually! The only reason I haven’t is that it’d be nicer if the iterator returned a reference for each element rather than a pointer, as none of them can ever be null.
Another approach would be to give Component some begin/end methods to make it directly iterable. Or to have a getChildComponent() method that returns some kind of iterator adapter class.
Actually, I think a better addition would be something like getChildComponentsOfClass() which would return some kind of iterable array. When looking for a parent, you generally only expect to find a single object, but when looking through children, a more common use-case would be iterating 1 or more objects of that class.
Absolutely, fair point! This would really fascilitate the (quite nice) pattern where you add special capabilities to certain child components, and then need to find them all from the parent.