Linked Questions
1,781 questions linked to/from Why can templates only be implemented in the header file?
215 votes
3 answers
178k views
"Undefined reference to" template class constructor [duplicate]
I have no idea why this is happenning, since I think I have everything properly declared and defined. I have the following program, designed with templates. It's a simple implementation of a queue, ...
76 votes
6 answers
67k views
Template issue causes linker error (C++) [duplicate]
I have very little idea what's going in regards to C++ templates, but I'm trying to implement a function that searches a vector for an element satisfying a given property (in this case, searching for ...
129 votes
3 answers
95k views
Why do I get "unresolved external symbol" errors when using templates? [duplicate]
When I write C++ code for a class using templates and split the code between a source (CPP) file and a header (H) file, I get a whole lot of "unresolved external symbol" errors when it comes to ...
49 votes
6 answers
33k views
C++ template, linking error [duplicate]
I have a problem in calling a template class I have. I declared a new type name Array, which is a template; In the .hpp file: template <typename T> class Array { public: Array(); }; In the ....
55 votes
3 answers
50k views
Undefined reference error for template method [duplicate]
This has been driving me mad for the past hour and a half. I know it's a small thing but cannot find what's wrong (the fact that it's a rainy Friday afternoon, of course, does not help). I have ...
38 votes
4 answers
69k views
c++ template and header files [duplicate]
So, I heard that C++ templates shouldn't be separated into a header (.h) and source (.cpp) files. For instance, a template like this: template <class T> class J { T something; }; Is this ...
44 votes
4 answers
17k views
Why should the implementation and the declaration of a template class be in the same header file? [duplicate]
Why should the implementation and the declaration of a template class be in the same header file? Could any of you explain it by example?
25 votes
4 answers
25k views
"Undefined symbols" linker error with simple template class [duplicate]
Been away from C++ for a few years and am getting a linker error from the following code: Gene.h #ifndef GENE_H_INCLUDED #define GENE_H_INCLUDED template <typename T> class Gene { public: ...
14 votes
5 answers
19k views
Do template class member function implementations always have to go in the header file in C++? [duplicate]
Normally when I create a class, I create a header and a source for that class. I have heard that with a template class, you have to put the function implementation in the header. I tried doing it both ...
17 votes
2 answers
42k views
Template class constructor [duplicate]
Ok guys... I have following class #include <functional> template <typename TValue, typename TPred = std::less<TValue>> class BinarySearchTree { struct TNode { TValue ...
8 votes
3 answers
25k views
C++ keep getting error LNK2019: unresolved external symbol [duplicate]
I tried to google this but always come back with different issues. I am getting 3 unresolved externals when I try to compile this program: 1>main.obj : error LNK2019: unresolved external symbol "...
17 votes
5 answers
11k views
Include .cpp file? [duplicate]
Possible Duplicate: Why can templates only be implemented in the header file? I've been trying around with C++ recently. At the moment I'm trying to program something I'm sure everone has done at ...
8 votes
4 answers
14k views
Template Class – Symbols not found [duplicate]
I've seen a few related posts, but I can't really make sense of what I need to do to fix a program I'm making for my entry-level C++ class. My errors are: Build Final Project of project Final ...
7 votes
1 answer
8k views
Linker error when using a template class? [duplicate]
I'm getting an "unresolved external symbol "public:__thiscall hijo<int>::hijo<int>(void)" referenced in function_main I started a new project cause I was having this same error on another ...
3 votes
2 answers
25k views
ERROR LNK2019:unresolved external symbol, c++ [duplicate]
I have written a template class, for a map/dictionary data structure, and keep getting this strange error (ERROR LNK2019:unresolved external symbol) Code: AssArray.h: #pragma once template <...