Hi, I am having some problems with a template structure I am using and was hoping that someone around here could give me a hint. The code I am using works fine on the Visual Studio 8 compiler from MS but it does not compile on the gcc. I stripped it down as good as I could and it looks valid to me but still it only compiles with VS8 and not with the GCC. The interesting thing is that it does work when I only use one template parameter. I am using gcc version 4.2.4 (Debian 4.2.4-3). Could this be a bug in the gcc or is this simply not valid c++ code and the VS8 is only generous? The stripped down example: #include<iostream> template< size_t sizeValue, typename NumericType> class Base { protected: NumericType n; public: typedef NumericType val_t; Base(val_t t):n(t) { } }; template< size_t sizeValue, typename unusedType > class Derived; template< size_t sizeValue > class Derived<sizeValue, int> : public Base<sizeValue, int> { public: Derived() : Base<sizeValue, val_t>(1) { } }; int main() { Derived<12, int> d; } The error message I get is the following templateTest.cpp: In constructor Derived<sizeValue, int>::Derived(): templateTest.cpp:32: error: val_t was not declared in this scope templateTest.cpp:32: error: template argument 2 is invalid templateTest.cpp: In constructor Derived<sizeValue, int>::Derived() [with unsigned int sizeValue = 12u]: templateTest.cpp:39: instantiated from here templateTest.cpp:32: error: no matching function for call to Base<12u, int>::Base() templateTest.cpp:13: note: candidates are: Base<sizeValue, NumericType>::Base(NumericType) [with unsigned int sizeValue = 12u, NumericType = int] templateTest.cpp:7: note: Base<12u, int>::Base(const Base<12u, int>&) Thanks in advance Michael Kaes
#include<iostream> template< size_t sizeValue, typename NumericType> class Base { protected: NumericType n; public: typedef NumericType val_t; Base(val_t t):n(t) { } }; template< size_t sizeValue, typename unusedType > class Derived; template< size_t sizeValue > class Derived<sizeValue, int> : public Base<sizeValue, int> { public: Derived() : Base<sizeValue, val_t>(1) { } }; int main() { Derived<12, int> d; }