c++ - typenamed iterator is not a type -
i'm writing templated class, involves use of iterators. i've found many questions how need typename iterator if you're using template, i'm wondering why it's still not working.
#pragma once #include <iterator> #include <list> #include <tuple> template <class t> class quack { private: std::list<t> data; typename std::list<t>::iterator iter; public: quack(); void insert(t dat); std::tuple<t, t> poppop(); private: //error: 'iter' not name type iter binarysearch(t tofind, std::list<t>::iterator min, std::list<t>::iterator max); };
i tried typedef typename std::list<t>::iterator iter;
, throws error "std::list::iterator not type"
so given i'm using typename
, i'm doing wrong?
i'm using g++ 4.4.5 argument -std=c++0x, if it's relevant.
you want typedef there (right you're declaring object named iter
):
typedef typename std::list<t>::iterator iter;
also, need typename
in declaration of binarysearch
:
iter binarysearch(t tofind, typename std::list<t>::iterator min, typename std::list<t>::iterator max);
of course, can use iter
@ point:
iter binarysearch(t tofind, iter min, iter max);
Comments
Post a Comment