вот минимальный проблемный код1:
2: template <class type>
3: class c1 {
4: public:
5:
6: class c2 {
7: public:
8:
9: int a;
10: int b;
11: c2 ( int a, int b ) : a (a), b (b) {}
12: };
13:
14: c2 add ( int, int );
15:
16: type d;
17: };
18:
19: template <class type>
20: c1<type>::c2
21: c1<type>::add ( int a, int b ) {
22: return c2 (a,b);
23: }
24:
25: int main () {
26: c1<int> A;
27: }
28:
вот как реагируют разные компиляторы на этот код
1:
%> gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.2 [FreeBSD] 20040728
%> g++ test.cpp
test.cpp:21: error: expected constructor, destructor, or type conversion before "c1"
test.cpp:21: error: expected `;' before "c1"
%>
2:
%> gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)
%> g++ test.cpp
test.cpp:21: warning: `typename c1<type>::c2' is implicitly a typename
test.cpp:21: warning: implicit typename is deprecated, please see the
documentation for details
%>
3:
%> gcc -v
Using builtin specs.
gcc version 2.95.4 20020320 [FreeBSD]
%> g++ test.cpp
%>
никаких ошибок и предупреждений
как заставить это код компилироваться под gcc 3.4.2?