Hi,
There may be bug with respect to templates in g++. The below
program does not compile. It may be some silly mistake on my part. I've
included the diagnostic and version information respectively.
Sincerely,
Ben
#include <vector>
using namespace std;
template <class T>
class TTable1 {
T fType;
public:
void debug() {
vector<T>::iterator it; //this is the line in question (10)
}
};
int main() {
}
$ g++ testTemplate.cpp
testTemplate.cpp: In member function `void TTable1<T>::debug()':
testTemplate.cpp:10: error: expected `;' before "it"
$ g++ --version
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It's cygwin version above running on Windows XP Professional.
Version 5.1 (Build 2600.xpsp.050928-11517 : Service Pack 2 (Windows
version)
Ben
You need to prefix your 'vector<T>::iterator it' declaration with
'typename ' to inform gcc that this is your intention:
typename vector<T>::iterator it;
That should solve your problem.
Rgds
Paul