• Create Account

### #Actualmrjones

Posted 24 May 2012 - 02:58 AM

Templates are sort-of header only. Meaning that compiler can't resolve template in linking phase and all method definitions must be available during compilation. This means that you should either put everything in your source file to header file and remove the source file or do some hack like this:
// LinkedList.h
... class declaration etc ...

// Do something that's generally a really bad idea

#endif


// LinkedList.cpp
// Add ifdef, such that contents of this file are only compiled, if it is included from LinkedList.h

... Methods and everything else typically in a .cpp file...

#endif


### #2mrjones

Posted 24 May 2012 - 02:55 AM

Templates are sort-of header only. Meaning that compiler can't resolve template in linking phase, but all method definitions must be available during compilation. This means that you should either put everything in your source file to header file and remove the source file or do some hack like this:
// LinkedList.h
... class declaration etc ...

// Do something that's generally a really bad idea

#endif


// LinkedList.cpp
// Add ifdef, such that contents of this file are only compiled, if it is included from LinkedList.h

... Methods and everything else typically in a .cpp file...

#endif


### #1mrjones

Posted 24 May 2012 - 02:51 AM

Templates are sort-of header only. Meaning that compiler can't resolve template in linking phase, but all method definitions must be available during compilation. This means that you should either put everything in your source file to header file and remove the source file or do some hack like this:
// LinkedList.h
... class declaration etc ...

// Do something that's generally a really bad idea

#endif


// LinkedList.cpp
// Add ifdef, such that contents of this file are only compiled, if it is included from LinkedList.h