4. What is the output of the following C++ program?

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iostream>
#include <memory>
#include <vector>

class A
{
public:
    A() : m_size(sizeof(A)) { }

public:
    virtual void f() const { std::cout << 1; }
    virtual ~A() { }

public:
    static bool compare(const A *a, const A *b)
    {
        assert(a != nullptr);
        assert(b != nullptr);
        return a->m_size < b->m_size;
    }

protected:
    size_t m_size;
};

class B 
    : public A
{
public:
    B() : m_b(nullptr) { m_size = sizeof(B); }

public:
    virtual void f() const { std::cout << 2; }

private:
    char *m_b;
};

class C
    : public A
{
public:
    C() { m_size = sizeof(C); }

public:
    virtual void f() const { std::cout << 3; }

private:
    static int *m_c;
};

int *C::m_c = nullptr;

int main()
{
    std::vector<A*> v({ new C, new B, new A});
    std::stable_sort(v.begin(), v.end(), A::compare);
    std::for_each(v.begin(), v.end(), std::mem_fn(&A::f));
    std::cout << std::endl;
    std::for_each(v.begin(), v.end(), std::default_delete<A>());

    return 0;
}