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

#include <iostream>

class A
{
public:
    A() { f(); }

    virtual ~A() { }

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

class B
    : public A
{
public :
    B() { f(); }

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

int main()
{
    const A *a = new B;
    delete a;

    std::cout << std::endl;

    return 0;
}