While @Lightness's answer is correct as far as it goes, it still doesn't point toward how you should be doing this. Most times that you write an explicit loop using iterators, it's a mistake (and this is no exception). Most uses of std::endl
are also mistakes (and this doesn't look like an exception in that respect either).
So, instead of writing an explicit loop, then explicitly dereferencing the iterator, etc., and finally taking his advice (correct though it is) to get the syntax correct, you should be thinking in terms of getting rid of essentially all of that, and using generic algorithms to do the job instead.
In this case, you have an input collection. For each item in that input collection, you're invoking a function, then writing the result to some output collection. That pretty much describes std::transform
, so it's probably a decent fit for the job at hand.
std::transform(customClassCustomVectorArray.begin(),
customClassCustomVectorArray.end(),
mem_fun(&customClass::customMember),
std::ostream_iterator<result_type>(std::cout, "\n"));
This uses result_type
to represent the type of the result from invoking your member function. Having to explicitly specify that result type is something of a liability of this technique, but at least IMO, its strengths substantially outweigh that minor liability.
Probably the most obvious strength is that the definition of std::transform
is (reasonably) well known and standardized, so anybody who knows C++ (at all well) immediately has a pretty fair idea of what this is supposed to do as a whole--invoke some function on every item in a range, and write the returned value to some destination.