Indeed, I've tried what it told me, but unfortunately with some mistakes. No matter. Thank you a lot for your reply.
On 31 Bře, 21:28, Thomas Maeder <[EMAIL PROTECTED]> wrote: > gx <[EMAIL PROTECTED]> writes: > > > template<class T> bool find0(const std::vector<T> &v){ > > for(std::vector<T>::const_iterator it=v.begin(); it!=v.end(); + > > +it){ > > if(!*it) > > return true; > > } > > return false; > > } > > > I believe that the problem is in the definition of template function. > > > When I try to compile a source code with g++/minigw32-g++ I obtain > > this output: > > > $ g++ -Wall -pedantic pokus2.cpp > > pokus2.cpp: In function 'bool find0(const std::vector<T, > > std::allocator<_CharT> >&)': > > pokus2.cpp:17: error: expected `;' before 'it' > > pokus2.cpp:17: error: 'it' was not declared in this scope > > pokus2.cpp: In function 'bool find0(const std::vector<T, > > std::allocator<_CharT> >&) [with T = double]': > > pokus2.cpp:38: instantiated from here > > pokus2.cpp:17: error: dependent-name > > 'std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as > > a non-type, but instantiation yields a type > > pokus2.cpp:17: note: say 'typename > > std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is > > meant > > > I would gladly welcome your replies. > > Well, the error message says it all. have you tried doing what it > tells you to? > > I.e. > > for (typename std::vector<T>::const_iterator it = v.begin(); > it!=v.end(); > ++it) > > If you don't write typename, the compiler has to assume that > const_iterator names something that is not a type. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus