Archived

This topic is now archived and is closed to further replies.

templated classes and multiple files

This topic is 5823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok heres the problem... i have written a basic templated linked list class (it works, ive tested) and i want to split it up into multiple files ala main.cpp list.h and list.cpp in list.h there is template class LINKEDLIST{ public: //variables omitted for brevity void add_node(t data); } in list.cpp there is #include "list.h" template void LINKEDLIST::add(t data) { //this actually does stuff when i dont cut out all the code } and in main.cpp there is #include "list.h" int main(void) { LINKEDLIST bla; } now the thing above compiles.... but when i add the following to it bla.add(6); i get this error undefined reference to LINKEDLIST::add(int) anyone know why this is? ps it only does this with templated classes... normal ones work fine thanx to any who respond

Share this post


Link to post
Share on other sites