From: Jan Reimers Subject: Templates To: djgpp AT sun DOT soe DOT clarkson DOT edu Date: Mon, 27 Jun 94 16:55:13 PDT Hello I have a question about generating instances of template functions. I am using #pragma implementation "file name" and #pragma interface coupled with typedef statements to control the generation of my template classes. For example: // file maketmpl.cc #pragma implementation "myclass.h" #pragma implementation "myclass.cc" #include "myclass.h" //Class declaration. #include "myclass.cc" //Definition of member functions and friend functions. typedef MyClass MakeInt; //force genration of template code typedef MyClass MakeInt; //for various parameterized types. // end of maketmpl.cc The compiler then generates code for all the member functions of MyClass BUT no code for the friend functions! Borland C++ 4.0 also generates no friend functions. Turbo C++ 3.0 does generate all friend functions. The only way that I have found to get around this in djgpp and BC4 is to write a messy little function (called 'junk()'!) which for example, declares instances of MyClass and calls all friend functions. This is very messy and difficult to maintain accuratly. Has anybody else out there in email land, encountered the same problem? If so, what did you do? I have recently migrated from FORTRAN to C++, so maybe I am missing something simple. Any suggestions would be appreciated. Thanks in advance. ################################ Jan N. Reimers Research Scientist Moli Energy (1990) Ltd. Tel: (604)-465-7911 FAX: (604)-465-4398 email: janr AT molienergy DOT bc DOT ca ################################