error when importing library in c ++

1

I need help. I created a library and at the beginning I put the:

#ifndef _PILA_H
#define _PILA_H
......
......
#endif

but it causes problems when importing it into two different .cpp files, I also import it into another library .h both libraries have the #ifdef ...

I get the multiple definition error

someone who knows what the problem is?

this is the code of the library

#ifndef PILA_H
#define PILA_H

#include <cstddef>

using namespace std;


class Nodo {
    public:
        float x;
        float y;
        Nodo *siguiente;
};


class Pila {
private:
    Nodo *tope;

public:
    Pila();
    void insertar(float x, float y);
    Nodo sacarPila();
    Nodo verTope();
    bool vacia();
};

Pila::Pila(){
    tope = NULL;
}

void Pila::insertar(float x, float y)
{
    Nodo *nuevo;
    nuevo = new Nodo();
    nuevo->x = x;
    nuevo->y = y;
    if (tope == NULL)
    {
        tope = nuevo;
        nuevo->siguiente = NULL;
    }
    else
    {
        nuevo->siguiente = tope;
        tope = nuevo;
    }
}


Nodo Pila::sacarPila(){
    if (tope != NULL)
    {
        Nodo *bor = tope;
        tope = tope->siguiente;
        return *bor;
    }
    else
    {
        Nodo *bor = NULL;
        return *bor;
    }
}

Nodo Pila::verTope(){
    if (tope != NULL)
        return *tope;
    else
    {
        Nodo *bor = NULL;
        return *bor;
    }
} 

bool Pila::vacia(){
    if (tope == NULL)
        return true;
    return false;
}


#endif

    
asked by Amaury 15.04.2018 в 02:42
source

0 answers