I'm struggling with getting template specialization to work. Even with this simple example code it won't work.
PriorityQueue.h
template<class T>
class PriorityQueue {
public:
T remove();
};
template<>
class PriorityQueue<string> : public PriorityQueue<string> {
public:
string remove();
};
PriorityQueue.cpp
string PriorityQueue<string>::remove() {
//implementation
}
I get this error message:
.../PriorityQueue.h39:38: error: :39:38: error: base class has incomplete type
base class has incomplete type
class PriorityQueue<string> : public PriorityQueue<string> {class PriorityQueue<string> : public PriorityQueue<string> {
~~~~~~~^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
EDIT
I've now changed the header to only specialize the member function, but still get errors. I should probably show you the whole code, so here's a link to the project on Github with the recent updated code.
This is the new error message:
duplicate symbol __ZN13PriorityQueueINSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEE6removeEv in:
CMakeFiles/Oblig2_Oppg2.dir/main.cpp.o
CMakeFiles/Oblig2_Oppg2.dir/PriorityQueue.cpp.o
ld: 1 duplicate symbol for architecture x86_64