I can't make this code to compile due to an undefined reference error. The classes were more complex, but I took out the rest and its still not compiling.
I believe the problem is when trying to create a class based on a template, with new and my implementation class of that template... I really appreciate any help, cause I've lost like two hours with this.
Here is the code.
/* the main.cpp file */
int main() {
// this is the line that triggers the error: "undefined reference to `ListaImp<int>::ListaImp()"
TADLista<int> * list = new ListaImp<int>; // this is the one
list->Vacia();
return 0;
}
/* TEMPLATE CLASS */
#ifndef TADLISTA_H_
#define TADLISTA_H_
template<class T>
class TADLista {
public:
virtual ~TADLista(){}
virtual void Vacia()=0;
};
#endif /* TADLISTA_H_ */
/* CLASS LISTAIMP */
#ifndef LISTAIMP_H_
#define LISTAIMP_H_
#include "TADLista.h"
template<class T>
class ListaImp: public TADLista<T> {
public:
ListaImp();
~ListaImp();
void Vacia();
};
#endif /* LISTAIMP_H_ */
/* THE CPP FILE */
#include "ListaImp.h"
#define NULL 0
template<class T>
ListaImp<T>::ListaImp() {}
template<class T>
ListaImp<T>::~ListaImp() {}
template <class T>
void ListaImp<T>::Vacia(){return true;}