From: Sean Melody Newsgroups: comp.os.msdos.djgpp Subject: Re: C++ templates question Date: Fri, 17 Apr 1998 17:11:46 -0500 Organization: Northwestern University, Evanston, IL, US Lines: 77 Message-ID: <3537D3A2.A878B8DD@STOP.SPAMMERS.nwu.edu> References: <19980417 DOT 7001502 AT seneca> NNTP-Posting-Host: hin082083.res-hall.nwu.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk string.h is c strings string is c ++ strings. Try include Might work, might not. schuster AT eev DOT e-technik DOT uni-erlangen DOT de wrote: > > 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() > { > > }