Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*---------------------------------------------------------*/
- template <class Elemento>
- class Lista
- {
- private:
- struct nodoLista
- {
- Elemento valor;
- nodoLista * sig;
- };
- nodoLista * lista;
- public:
- Lista ();
- ~Lista();
- void inserta_al_principio(Elemento valor);
- void inserta_al_final(Elemento valor);
- nodoLista * devuelve_nodo(int valor);
- };
- /*---------------------------------------------------------*/
- template <class Elemento>
- nodoLista * lista<Elemento>::devuelve_nodo(int posicion)
- {
- nodoLista * it = lista;
- int cont = 1;
- while (it != 0)
- {
- if (cont == posicion)
- return it;
- it = it->sig;
- cont++;
- }
- }
- /*---------------------------------------------------------*/
- int main()
- {
- Lista<int> lista;
- ...
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement