Help, heritage, polymorphism or parametric

Well, i'm a beginner in c++, my teacher told us to make a class node and other class dipole, but there's a error or something, i don't know

And in the console is "undefined reference dipole<int>::dipole" or something like that

PS: sorry if i said something wrong i'm so bad talking english xD. So the codes is in spanish

node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef NODO_H
#define NODO_H

template <class T>
class Nodos
{
	private:
		T dato;
		Nodos<T> *sig;
		Nodos<T> *ant;

	public:
		Nodos(); //Constructor
		Nodos<T>* ver_siguiente();
		Nodos<T>* ver_anterior();
		T ver_dato();
		T asignar_dato (T);
		Nodos<T>* next (Nodos<T>*);
		Nodos<T>* before (Nodos<T>*);
		~Nodos(){} //Destructor
};

#endif 



node.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<nodoG.h>

template <class T>
Nodos<T>::Nodos()
{
	this->sig=0;
	this->ant=0;
	this->dato=0;
}

template <class T>
Nodos<T>* Nodos<T>::ver_siguiente()
{
	return(this->sig);
}

template <class T>
Nodos<T>* Nodos<T>::ver_anterior()
{
	return(this->ant);
}

template <class T>
T Nodos<T>::ver_dato()
{
	return(this->dato);
}

template <class T>
T Nodos<T>::asignar_dato (T flot)
{
	return (this->dato=flot);
}

template <class T>
Nodos<T>* Nodos<T>::next(Nodos* smt)
{
	this->sig=smt;
}

template <class T>
Nodos<T>* Nodos<T>::before(Nodos* smt)
{
	this->ant=smt;
}


dipole.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef DIPOLO_H
#define DIPOLO_H
#include<nodoG.h>

template <class T>
class dipol : public Nodos<T>
{
	private:
		Nodos<T>* inicio;
		Nodos<T>* fin;
		int tope;

	public:
		dipol();
		T ver_inicio();
		T ver_fin();
		void agregar_inicio(T);
		void agregar_fin(T);
		int sacar_inicio();
		int sacar_fin();
		int ver_tope();

};

#endif


dipole.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<iostream>
#include<dipoloG.h>
#include<nodoG.h>


template <class T>
dipol<T> ::dipol()
{
	this->inicio=0;
	this->fin=0;
	this->tope=0;
}

template <class T>
T dipol<T>::ver_inicio()
{
	return(this->inicio->ver_dato());
}
template <class T>
T dipol<T>::ver_fin()
{
	return(this->fin->ver_dato());
}

template <class T>
void dipol<T>::agregar_inicio(T dato)
{
	Nodos<T>* dat= new Nodos<T>;

	dat->asignar_dato(dato);
	dat->next(this->inicio);
	this->inicio=dat;

	if(this->tope==0)
		this->fin=this->inicio;
	this-> tope= this->tope+1;
}
template <class T>
void dipol<T>::agregar_fin(T dato)
{
	Nodos<T>* dat= new Nodos<T>;

	dat->asignar_dato(dato);
	dat->before(this->fin);
	this->fin=dat;

	if(this->tope==0)
		this->inicio=this->fin;

	this-> tope= this->tope+1;
}

template <class T>
int dipol<T>::sacar_inicio()
{
	if(this->tope>2)
	{
		Nodos<T>* aux= this->inicio;
		this->inicio=aux->ver_siguiente();
		this->tope=tope-1;
	}
	else if(this->tope==2)
	{
		this->inicio=this->fin;
		this->tope=tope-1;
	}
	else if(this->tope==1)
	{
		this->inicio=this->fin=0;
		this->tope=tope-1;
	}
	else
		return 1;
}

template <class T>
int dipol<T>::sacar_fin()
{
	if(this->tope>2)
	{
		Nodos<T>* aux= this->fin;
		this->fin=aux->ver_anterior();
		this->tope=tope-1;

	}
	else if(this->tope==2)
	{
		this->fin=this->inicio;
		this->tope=tope-1;
	}
	else if(this->tope==1)
	{
		this->inicio=this->fin=0;
		this->tope=tope-1;
	}
	else
		return 1;
}

template <class T>
int dipol<T>::ver_tope()
{
	return(this->tope);
}


main
1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
#include<dipoloG.h>
//#include<nodoG.h>
#include<unistd.h>

int main()
{
	int datosi[20];
	dipol <int> ent;//here is the problem
	return 0;
}



Thank you.
Last edited on
For future reference, please post the entire error message.

Your problem is that you can't split template definitions up into different files like you have there; all of the member function definitions must be in the header file instead of in a separate cpp file.
Topic archived. No new replies allowed.