Hi Tim,Yes, I'm using 3.3 here and the begin() and end() methods works fine...
this seems to be a speciality of the gcc 3.4 compiler... i'll have to check for that - a bit later
typename
and template
keywords to disambiguate dependent names, as required by the C++
standard.
struct K { typedef int mytype_t; }; template <class T1> struct A { template <class T2> struct B { void callme(void); }; template <int N> void bar(void) { // Use 'typename' to tell the parser that T1::mytype_t names // a type. This is needed because the name is dependent (in // this case, on template parameter T1). typename T1::mytype_t x; x = 0; } }; template <class T> void template_func(void) { // Use 'template' to prefix member templates within // dependent types (a has type A<T>, which depends on // the template parameter T). A<T> a; a.template bar<0>(); // Use 'template' to tell the parser that B is a nested // template class (dependent on template parameter T), and // 'typename' because the whole A<T>::B<int> is // the name of a type (again, dependent). typename A<T>::template B<int> b; b.callme(); } void non_template_func(void) { // Outside of any template class or function, no names can be // dependent, so the use of the keyword 'typename' and 'template' // is not needed (and actually forbidden). A<K> a; a.bar<0>(); A<K>::B<float> b; b.callme(); }But I've checked the code and template and typename seems well placed...
template <typename T> struct B { int m; int n; int f (); int g (); }; int n; int g ();
template <typename T> struct C : B<T> { void h () { m = 0; // error f (); // error n = 0; // ::n is modified g (); // ::g is called } };
You must make the names dependent, e.g. by prefixing them with this->
.
Here is the corrected definition of C<T>::h
,
template <typename T> void C<T>::h () { this->m = 0; this->f (); this->n = 0 this->g (); }