Linker errors with templates

  • Thread starter Generic Usenet Account
  • Start date
G

Generic Usenet Account

I am "plugging in" a class type into an STL map definition and I am
getting linker errors unless all my class definitions are defined in
the header file, as opposed to a separate source file. This is
happening on the following C++ compiler:
gcc version 3.3.1

My question is whether this is standard behavior, or just a quirk of
the compiler that I am using.

Thanks
 
D

David Harmon

On 19 Nov 2004 11:03:34 -0800 in comp.lang.c++, "Generic Usenet
Account said:
I am "plugging in" a class type into an STL map definition and I am
getting linker errors unless all my class definitions are defined in
the header file, as opposed to a separate source file.

This issue is covered in Marshall Cline's C++ FAQ. See the topics
"[34.12] Why can't I separate the definition of my templates class
from it's declaration and put it inside a .cpp file?" and
"[34.13] How can I avoid linker errors with my template functions?".
It is always good to check the FAQ before posting. You can get the
FAQ at:
http://www.parashift.com/c++-faq-lite/

Crosspost deleted. This question is off-topic for comp.sources.d.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top