This code gives a linker error:
// engine_container.hpp
#ifndef _ENGINE_CONTAINER_HPP_
#define _ENGINE_CONTAINER_HPP_
#include "globals.hpp"
#include <vector.h>
template <typename t_type>
class Engine_container_interface
{
public:
Engine_container_interface() { }
virtual bool m_add_stuff(t_type *a_stuff, ID &a_new_stuff_id) { }
}; // end class Engine_container_interface
template <typename t_type>
class Engine_container_STL : public Engine_container_interface<t_type>
{
public:
Engine_container_STL();
virtual bool m_add_stuff(t_type *a_stuff, ID &a_new_stuff_id);
protected:
vector<t_type> m_stuff_vector;
ID m_references;
}; // end class Engine_container_STL
#endif // #ifndef _ENGINE_CONTAINER_HPP_
// engine_container.cpp
#include "engine_container.hpp"
template <typename t_type>
bool Engine_container_STL<t_type>::m_add_stuff(t_type *a_stuff, ID &a_new_stuff_id)
{
m_stuff_vector.push(*a_stuff);
a_new_stuff_id = m_stuff_vector.size();
}
template <typename t_type>
Engine_container_STL<t_type>::Engine_container_STL()
{
m_references = 0;
} // end Engine_container_STL<t_type>::Engine_container_STL()
And when i try to :
Engine_container_interface<VERTEX> *verts_container;
...
verts_container = new Engine_container_STL<VERTEX>;
i get 2 linker errors:
[Linker error] undefined reference to `Engine_container_STL<VERTEX>::Engine_container_STL()'
[Linker error] undefined reference to `Engine_container_STL<VERTEX>::Engine_container_STL()'
What am i doing wrong?