* gcc2.95 - 3.2 conversion
@ 2003-07-02 21:28 Michael van Rooyen
2003-07-02 21:41 ` Martin York
0 siblings, 1 reply; 2+ messages in thread
From: Michael van Rooyen @ 2003-07-02 21:28 UTC (permalink / raw)
To: gcc-help
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.)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: gcc2.95 - 3.2 conversion
2003-07-02 21:28 gcc2.95 - 3.2 conversion Michael van Rooyen
@ 2003-07-02 21:41 ` Martin York
0 siblings, 0 replies; 2+ messages in thread
From: Martin York @ 2003-07-02 21:41 UTC (permalink / raw)
To: Michael van Rooyen, gcc-help
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.)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-07-02 21:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-02 21:28 gcc2.95 - 3.2 conversion Michael van Rooyen
2003-07-02 21:41 ` Martin York
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).