Hey.
I ran into a problem recently, where code that i wrote on MSVC doesn't compile on GNU. Here is a sample:
This code gives me the following error on GNU. Now to fix it i need to do this:Code:#include <iostream.h> template <typename T> class Base { protected: class Test { public: T entry; }; }; template <typename T> class Child: public Base<T> { public: void add(); }; template <typename T> void Child<T>::add() { Base<T>::Test* test = new Base<T>::Test(); } int main() { Child<int> child; child.add(); return 0; };
Now this is an annoying thing to have to write every single time i use it. Same with teh Base<T>:: which was not required on MSVC.Code:typename Base<T>::Test* test = new typename Base<T>::Test();
Sorry about a post about GNU, but i figured that differences in c++ compilers would be known around here. I like the MS way of doing it, saves a bunch of code that just complicates everything. Is there a way to get similar behavior on GNU compilers?
Thanks in advance,
Quell




Reply With Quote