I'm unable to get template code that builds with g++ 3.4.x to link successfully in g++ 4.0.x I'd appreciate any suggestions. A search in bug reports in for 4.0 didn't show me anything that seemed to fit this.
Code for a simplified situation is presented below. In the link stage, g++ says: [EMAIL PROTECTED]:~/tests> g++ ATemplateMain.cpp ATemplate.cpp /tmp/cc4mEu4b.o: In function `main': ATemplateMain.cpp:(.text+0x20): undefined reference to `ATemplate<int>::GetValue() const' ATemplateMain.cpp:(.text+0x51): undefined reference to `ATemplate<float>::GetValue() const' collect2: ld returned 1 exit status Here is the code: // ATemplate.h template <class T> class ATemplate { T const n; public: ATemplate () : n (1) { } T GetValue () const; }; // ATemplateInst.h #include "ATemplate.h" template class ATemplate<int>; template class ATemplate<float>; // ATemplate.cpp #include "ATemplateInst.h" template <class T> T ATemplate<T>::GetValue () const { return n; } // ATemplateMain.cpp #include <iostream> #include "ATemplateInst.h" int main () { ATemplate<int> intTemplate; ATemplate<float> floatTemplate; std::cout << "ATemplate<int>::n = " << intTemplate.GetValue() << std::endl; std::cout << "ATemplate<float>::n = " << floatTemplate.GetValue() << std::endl; return 0; } Thanks much... Tom _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus