gcc2.95 - 3.2 conversion

Michael van Rooyen michael.vanrooyen@babel.co.za
Wed Jul 2 21:28:00 GMT 2003


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.)



More information about the Gcc-help mailing list