From: schuster AT eev DOT e-technik DOT uni-erlangen DOT de Newsgroups: comp.os.msdos.djgpp Subject: C++ templates question Date: Fri, 17 Apr 1998 07:00:15 GMT Organization: Regionales Rechenzentrum Erlangen, Germany Lines: 80 Message-ID: <19980417.7001502@seneca> NNTP-Posting-Host: eev6.e-technik.uni-erlangen.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Content-Transfer-Encoding: 8bit Precedence: bulk Hi ! When writing some C++ code with djgpp, i've encountered the following problem with templates (I don't know if this is a bit off topic, but don't know if it's a general c++ question or a djgpp - c++ question either) Look at: #include template class test { int a; char r[34]; public: test(int integ, char* string); }; template test::test(int integ, char* string) { a=integ; strcpy(string,r); } int main() { test Ttest(1,"S"); } this works fine, but when changing to the following, the linker says undefined reference to the constructor of class test. (look at the position of test Ttest(1,"S") ) #include template class test { int a; char r[34]; public: test(int integ, char* string); }; template test::test(int integ, char* string) { a=integ; strcpy(string,r); } test Ttest(1,"S"); int main() { } if I change it to the next all works fine. Any idea why. Is this normal or djgpp - c++ spezific? Thanks Michi #include template class test { int a; char r[34]; public: test(int integ, char* string){ a=integ; strcpy(string,r); } }; test Ttest(1,"S"); int main() { }