Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Posted on 4 Aug 2009 at 6:00 AM
View this post at the Programmers Heaven C++ forum.
Dear fellow programmers,
I fail to get a typedef in a template class to compile, when using G++ 3.4.4 (compiled with 'g++ UnitMyClass.cpp'). But when I use C++ Builder 6's compiler (BCC32) it compiles successfully.
Below are the simplified code and error messages. Note that I already try to tackle the problem with four different syntaxes.
Google didn't give me the answer, I hope you will.
Thanks in advance, Bilderbikkel
|
The errors (for each version of MyMethod) are:
$ g++ UnitStorage.cpp
In file included from UnitStorage.cpp:5:
UnitStorage.h: In member function 'void MyClass<T>::MyMethod_1() const':
UnitStorage.h:15: error: expected init-declarator before "Iter"
UnitStorage.h:15: error: expected ',' or ';' before "Iter"
|
Surprisingly I actually knew that one!
It's because of GCC being strict with the standard and Borland ain't. You gotta write
typedef typename std::map<T,double>::const_iterator Iter;
However, I don't enough of the C++ standard to explain the details of that.
|
Thanks Lundin!
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.

This page has been created by the tool CodeToHtml