If I initialize the constructor with a string message because I get this message?

1

I am learning to make trees in a binary search and inside a class I put another class in private with the name "inside" then I created a pointer * miRaiz pointing to the class "in", then to my class "Out" in the public part there is an empty method which throws true or false in case "miRaiz" is not zero.

My question is Because the value of "miRaiz" changes if my Constructor receives a string and only because of this the value of "miRaiz" changes. I do not understand why this happens if I'm not grabbing changes to my pointer "miRaiz".

Thanks for your help here my code:

   #include <iostream>
    using namespace std;

template <class cualquier>
class Fuera
{
    class dentro
    {
    public:
        cualquier dato;
        dentro *puntDentroDer;
        dentro *puntDentroIzq;
        dentro(): puntDentroDer( 0 ),puntDentroIzq(0){}
        dentro(cualquier elemento):
                    dato(elemento), puntDentroIzq(0),puntDentroDer(0){} 
    };

    typedef dentro *puntDeDentro;

    void presentar(puntDeDentro algo) const;

    /*Atributo*/
    puntDeDentro miRaiz;
public:
    Fuera();
    Fuera(string Hola){cout << Hola;};
    bool vacio() const;

};

template <class cualquier>
inline Fuera<cualquier>::Fuera():miRaiz( 0 ){}

template <class cualquier>
inline bool Fuera<cualquier>::vacio() const
{
    return miRaiz == 0;
}

int main()
{
    Fuera<int> objeto("\nEspero que esto salga bien\n");
    cout <<  "El  Arbol de Sergio " <<  (objeto.vacio() ?  "esta" : "no esta") << " vacio\n " ;
    cout << "\nLendy\n";
    return 0;
}

Thanks for your help.

    
asked by Mucacran 13.03.2017 в 04:52
source

1 answer

3

Here

template <class cualquier>
inline Fuera<cualquier>::Fuera():miRaiz( 0 ){}

You're initializing myRaiz at 0.

Here

Fuera(string Hola){cout << Hola;};

no.

    
answered by 13.03.2017 / 05:07
source