Original Post
When I try to compile the following code with gcc-4.1, I get an error: expected primary-expression before '>' token. Visual C++ 2005 does accept the code. Can someone explain why gcc complains, and how to fix it?
#include <iostream>
using namespace std;
template <typename T> class Base {
public :
template <typename W> void f () {
cout << "f ()" << endl;
}
};
template <typename T> class Derived: Base <T> {
public :
template <typename W> void g () {
Base <T> :: f <W> (); // problematic line
}
};
int main () {
(new Derived <float> ()) -> g <int> ();
return 0;
}