This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc2.95 - 3.2 conversion
- From: Martin York <Martin dot York at veritas dot com>
- To: "Michael van Rooyen" <michael dot vanrooyen at babel dot co dot za>, <gcc-help at gcc dot gnu dot org>
- Date: Wed, 2 Jul 2003 17:44:36 -0400
- Subject: Re: gcc2.95 - 3.2 conversion
- Organization: Veritas
- References: <068701c340e0$e2a6cca0$0501a8c0@babel.co.za>
- Reply-to: Martin dot York at veritas dot com
Inside your class pvector add the following line:
typedef vector<P>::iterator iterator;
On Wednesday 02 July 2003 05:28 pm, Michael van Rooyen wrote:
> I'm in the process of converting from gcc 2.95.x to gcc 3.2, and I'm having
> a problem compiling the following bit of code that works fine under
> gcc2.95.x. I've done a brief search of the archives, but haven't found
> much of help. Does someone know why gcc doesn't like my 'iterator i'
> declaration below? Thanks, I'm stumped...
>
> #include <vector>
>
> using namespace std;
>
> template<class P> class pvector: public vector<P>
> {
> pvector(const pvector &);
> pvector &operator = (const pvector &);
>
> public:
>
> pvector()
> {
> }
>
> ~pvector()
> {
> for (iterator i=begin(); i!=end(); i++) // This is the problem
> line...
> delete *i;
> }
> };
>
> main()
> {
> pvector<char *> v;
> }
>
>
> Compiler output:
>
> test.cc: In destructor `pvector<P>::~pvector()':
> test.cc:19: parse error before `;' token
> test.cc: In destructor `void pvector<P>::pvector() [with P = char*]':
> test.cc:26: instantiated from here
> test.cc:19: `i' undeclared (first use this function)
> test.cc:19: (Each undeclared identifier is reported only once for each
> function
> it appears in.)