coding rules for template classes
John (Eljay) Love-Jensen
eljay@adobe.com
Wed Oct 18 22:12:00 GMT 2006
Hi Rolf,
Your questions are off topic for this forum.
> Does someone know of good coding rules for template classes, other than "put all in the .h file"?
Look here...
http://www.parashift.com/c++-faq-lite/templates.html
> If a template declaration is separated from the definition as to deliver declaration only to the user how will the definition get compiled to code?
It won't. The declaration+definition of a template is different from the instantiation of a template.
It would be like saying "I want to have 'inline int DoSomething(int, int);' declaration in the header for delivery to the user, but the definition elsewhere where the user can't see it. How will the definition get compiled (instantiated) to the user's code?"
> Do I need a third "instantiation" file? Is there some literature about this around?
There is something like this, but it doesn't do what you want. And it isn't supported very well by C++ compiler vendors in general, so tends to be used infrequently.
For GCC, look here...
http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html
HTH,
--Eljay
More information about the Gcc-help
mailing list