I have an error in the node class, when I try to do this with templates
the error that tells me: template arguments required for class Stack
Node class:
#ifndef NODO_H_INCLUDED
#define NODO_H_INCLUDED
#include <stdlib.h>
template <class T>
class Nodo{
private:
T Valor;
Nodo<T> *siguiente;
public:
Nodo(T v){
this->Valor=v;
this->siguiente=NULL;
}
void setSiguiente(Nodo<T> *sig){
this->siguiente=sig;
}
friend class Pila;
};
#endif // NODO_H_INCLUDED
Stack Class:
#ifndef PILA_H_INCLUDED
#define PILA_H_INCLUDED
#include "Nodo.h"
template <class T>
class Pila{
private:
Nodo<T> *Primero;
Nodo<T> *Ultimo;
bool PilaVacia(){
return (this->Primero==NULL);
}
public:
Pila(){
this->Primero=NULL;
this->Ultimo=NULL;
}
void Meter(T n){
Nodo<T> *nuevo=new Nodo<T>(n);
if(this->PilaVacia()){
this->Primero=nuevo;
}
else{
this->Ultimo->setSiguiente(nuevo);
}
this->Ultimo=nuevo;
}
};
#endif // PILA_H_INCLUDED
main.cpp
#include <iostream>
#include "Pila.h"
using namespace std;
int main()
{
Pila<int> pl;
pl.Meter(1);
cout << "Hello world!" << endl;
return 0;
}
[
At the moment it is the scheme that I must do, I don't know why it sends me to that error, I can't find a solution, I also don't know why it doesn't recognize the Stack class as a friend, if it already has the friend class Stack