help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple template compiling problem


From: Bernd Strieder
Subject: Re: simple template compiling problem
Date: Mon, 18 Jul 2005 16:05:09 +0200
User-agent: KNode/0.9.0

Hello,

Mikel Astiz wrote:

>     I'm sure it must be a compiler-configuration issue but, why can't
>     I
> compile this?
> 
> template <typename T>
> class CAutoVector : public std::vector<T>
> {
>       iterator it;
> };

The name "iterator" as you intended depends on the template arguments,
so you have to qualify it, and you have to tell the compiler to parse
it as typename, instead of e.g. a member name with the keyword
typename. In the case you got these errors from switching to gcc-3.4 or
later, see the docs of gcc-3.4 for a list of compiler changes. These
changes have been done to get compliant to the C++ standard. The
compiler has to reject your code.

template <typename T>
class CAutoVector : public std::vector<T>
{
      typename std::vector<T>::iterator it;
};

BTW, STL classes are generally not meant to be publically inherited
from.


Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]