Hi, since I upgraded from gcc 3.4 to 4.0.2 I have several problems with templates. The first one applies to friend template functions. While the following code
---8<--- template <class T> class FriendClass { // This line causes trouble friend T get_test<T> (const FriendClass &); protected: T test; }; template <class T> T get_test (const FriendClass<T> &fc) { return fc.test; } int main () { FriendClass<int> fc; get_test(fc); return 0; } --->8--- compiled without any problems before, it now gives the errors error: 'get_test' is neither function nor member function; cannot be declared friend error: expected ';' before '<' token in 4.0.2. But I'm pretty sure it's valid C++ code. Another problem concerns inheritance. Although members are declared protected and inheritance is public, the members are not transferred into the scope of the derived class: ---8<--- template <class T> class Base { protected: int test; }; template <class T> class Derived : public Base<T> { protected: // This doesn't work /* using namespace Base<T>; */ // This works but should be useless and is unhandy using Base<T>::test; void set_test () { test = 0; } }; int main () { return 0; } --->8--- One can override the problem by including a "using" statement for each member or accessing them with Base<T>:: but this is very unhandy. "using namespace" doesn't work, but should be unnecessary anyway. Anyone else experienced similar problems? I am using the gcc version shipped with SUSE 10.0. Many thanks, Emanuel _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus