keywords: C++, Constructor, Deconstrutor

Example:

class CA
{
public:

    CA()
    {
        printf("Father's Constructor\n");
    }

    virtual ~CA()
    {
        printf("Father's Deconstructor\n");
    }
};

class CB : public CA
{
public:

    CB()
    {
        printf("Child's Constructor\n");
    }

    ~CB()
    {
        printf("Child's Deconstructor\n");
    }
};

int main(char** args, int argc)
{
    CB* B = new CB();
    delete B;
    
    return 1;
}

Output:

Father's Constructor
Child's Constructor
Child's Deconstructor
Father's Deconstructor

He allowed himself to be swayed by his conviction that human beings are not born once and for all on the day their mothers give birth to them, but that life obliges them over and over again to give birth to themselves.― Gabriel García Márquez, Love in the Time of Cholera