On Feb 13, 6:45*pm, zdun777 <zdu...@gmail.com> wrote:
> When I try to compile (g++, ver=4.4.5) this code:
>
> #include <map>
> using namespace std;
>
> template<typename T> void fun()
> {
> * * * * map<int, int>::iterator b; * * *//OK
> * * * * map<T, int>::iterator a; * * * //NOK, error: expected ‘;’ before ‘a’
>
> }
>
> ,I get follow compiller error:
>
> error: expected ‘;’ before ‘a’
>
> Can you explain me why I can't define iterator in this way ?
Hi
Under g++ 4.5.0, in addition to above
error message, the compiler issues another message, which describes
and gives hint, what you have to do:
error: need 'typename' before std::map<T, int>::iterator' because
'std::map<T, int>'
is a dependent scope.
HTH
-- Saeed Amrollahi
|