Please take a look at this code:
template<class T> class A { class base { }; class derived : public A<T>::base { }; public: int f(typename A<T>::base& arg = typename A<T>::derived()) { return 0; } }; int main() { A<int> a; af(); return 0; }
Compilation generates the following error message in g ++:
test.cpp: In function 'int main()': test.cpp:25: error: default argument for parameter of type 'A<int>::base&' has type 'A<int>::derived'
The main idea (using the derived class as the default value for the base-reference-type argument) works in visual studio, but not in g ++. I have to publish my code on a university server, where they compile it with gcc. What can I do? Is something missing?
c ++ templates default-value g ++
Vincent
source share