Simple program won't compile

Rodrigo de Salvo Braz braz@students.uiuc.edu
Sun Jan 21 22:26:00 GMT 2001


Hi,

This program doesn't compile in gcc, although it does in a Borland
compiler. Basically, I can't use iterators of containers that are
arguments of template functions. Does anyone knows why? Thanks in advance!

#include <iostream>
#include <list> 
  
template <class Container>
void foo (Container& c)   
{
        list<char>::iterator j; // iterator ok.
        Container a = c;       // This is ok.
        Container::iterator i; // THIS IS THE PROBLEM.
                               // Message: parse error before ';'
}
 
int main (char* argv[], int argc)
{
        list<int> a;
        foo(a);
        return 0;
}




More information about the Gcc mailing list