Estou tentando fazer uma lista de funcionários. Na teoria, tudo parece correto, exceto pelo fato de aparecer o erro: undefined reference to
Alguém consegue achar o erro aqui?
Vou postar o código e o erro no final.
/*
* File: Funcionario.h
* Author: higornucci
*
* Created on 26 de Agosto de 2011, 20:14
*/
#ifndef FUNCIONARIO_H
#define FUNCIONARIO_H
#include <string>
using namespace std;
typedef class Funcionario {
private:
string nome;
long cpf;
string endereco;
string cidade;
string estado;
public:
string GetCidade() {
return cidade;
}
void SetCidade(string cidade) {
this->cidade = cidade;
}
long GetCpf() {
return cpf;
}
void SetCpf(long cpf) {
this->cpf = cpf;
}
string GetEndereco() {
return endereco;
}
void SetEndereco(string endereco) {
this->endereco = endereco;
}
string GetNome() {
return nome;
}
void SetNome(string nome) {
this->nome = nome;
}
string GetEstado() {
return estado;
}
void SetEstado(string uf) {
this->estado = uf;
}
} Funcionario;
#endif /* FUNCIONARIO_H */
/*
* File: ListaSimples.h
* Author: higornucci
*
* Created on 26 de Agosto de 2011, 20:49
*/
#ifndef LISTASIMPLES_H
#define LISTASIMPLES_H
template <class T>
class No {
private:
T info;
No<T> *prox;
public:
No(T info, No<T> *prox);
T GetInfo() {
return info;
}
void SetInfo(T info) {
this->info = info;
}
No<T>* GetProx() {
return prox;
}
void SetProx(No<T>* prox) {
this->prox = prox;
}
};
template <class T>
No<T>::No(T info, No<T> *prox) {
this->SetInfo(info);
this->SetProx(prox);
}
#endif /* LISTASIMPLES_H */
/*
* File: Lista.h
* Author: higornucci
*
* Created on 26 de Agosto de 2011, 21:25
*/
#ifndef LISTA_H
#define LISTA_H
#include <iostream>
#include "No.h"
template <class tipo>
class Lista{
private:
No <tipo> *inicio;
public:
Lista();
~Lista();
void insert(tipo elem);
int remove(tipo elem);
int empty();
No<tipo>* getInicio() const {
return inicio;
}
void setInicio(No<tipo>* inicio) {
this->inicio = inicio;
}
};
template <class tipo>
Lista<tipo>::Lista() {this->setInicio(NULL);}
template <class tipo>
int Lista <tipo> :: empty(){
if(!inicio)
return 1;
else
return 0;
};
template <class tipo>
void Lista <tipo> :: insert(tipo elem){
No <tipo> *ant=NULL, *atual,*novo;
novo = new No <tipo>(elem, NULL);
if(empty())
inicio=novo;
else{
atual=inicio;
while(atual!=NULL && atual->GetInfo() <= elem){
ant=atual;
atual=atual->GetProx();
}
if(ant==NULL){//inicio
novo->GetProx() = inicio;
inicio=novo;
}
else{//meio ou fim
ant->GetProx() = novo;
novo->GetProx() = atual;
}
}
}
template <class tipo>
int Lista <tipo> :: remove(tipo elem){
No <tipo> *ant=NULL,*atual;
if(empty())
return -1;
else{
atual = inicio;
while( atual && (atual->GetInfo() < elem)){
ant=atual;
atual=atual->GetProx();
}
if(atual!=NULL && atual->GetInfo() == elem){
if(ant==NULL)//inicio
inicio=atual->GetProx();
else//meio ou fim
ant->GetProx()=atual->GetProx();
delete atual;
return 0;
}
else
return 1; //nao existe
}
}
template <class tipo>
Lista <tipo> :: ~Lista(){
No <tipo> *p;
while(inicio!=NULL){
p=inicio;
inicio=inicio->GetProx();
delete p;
}
}
#endif /* LISTA_H */
/*
* File: main.cpp
* Author: higornucci
*
* Created on 26 de Agosto de 2011, 20:31
*/
#include <cstdlib>
#include <iostream>
#include <string>
#include "Funcionario.h"
#include "Lista.h"
/*
*
*/
int main(int argc, char** argv) {
Funcionario f;
f.SetNome("Higor");
f.SetCpf[telefone removido]);
f.SetEndereco("Rua Ipiranga, 1283");
f.SetCidade("Dourados");
f.SetEstado("MS");
Lista<Funcionario> lista;
lista.insert(f);
//cout << lista.getInicio()->GetInfo().GetCpf();
// lista.~Lista();
return 0;
}
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/higornucci/NetBeansProjects/CppApplication_2/main.cpp:25: undefined reference to `Lista<Funcionario>::Lista()'
/home/higornucci/NetBeansProjects/CppApplication_2/main.cpp:27: undefined reference to `Lista<Funcionario>::insert(Funcionario)'
collect2: ld returned 1 exit status