dimanche 28 octobre 2018

Destructor calling

I am new into C++ and I am currently learning it.
While I was exploring web and problems I came across on next code:

class A
{
    public:
    ~A() { cout << "A"; }

};

class B
{
    public:
        ~B() { cout << "B"; }
};


int main()
{
    A a;
    B b;

    return 0;
}

Output of looks like this:

BA

Can somebody explains why output looks like this?

Aucun commentaire:

Enregistrer un commentaire