Victor Bazarov
9/26/2008 7:37:00 PM
Hansel Stroem wrote:
> Is this legitimate STL code ? Compiler seems not to like the iterator ...
No, it's not. It's missing a keyword or two.
>
> template <typename Tn>
> ostream& operator<<(ostream& out, vector<Tn> VV)
You should look into passing the vector by a reference to const:
... (ostream& out, vector<Tn> const& VV)
> {
> for ( vector<Tn>::iterator it = VV.begin(); it != VV.end(); ++it )
Has to be
for ( typename vector<Tn>::iterator it = ...
(or, if you decide to pass the vector by a const ref,
for ( typename vector<Tn>::const_iterator it =
> {
> out << (*it);
> }
> return out << std::endl;
> }
>
>
> %icc BS.cc
> BS.cc(151): error: expected a ";"
> for ( vector<Tn>::iterator it = VV.begin(); it != VV.end(); ++it )
> ^
>
> BS.cc(151): error: identifier "it" is undefined
> for ( vector<Tn>::iterator it = VV.begin(); it != VV.end(); ++it )
> ^
>
> compilation aborted for BS.cc (code 2)
>
>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask