#include <iostream>
class A
{
public:
virtual void func(int a = 1)
{
std::cout << "class A::" << a << "\n";
}
};
class B : public A
{
public:
virtual void func(int a = 2)
{
std::cout << "class B::" << a << "\n";
}
};
void func(A& a) { a.func(); }
int main()
{
B b;
func(b);
b.func();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQQp7CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBmdW5jKGludCBhID0gMSkKICAgIHsKICAgICAgICBzdGQ6OmNvdXQgPDwgImNsYXNzIEE6OiIgPDwgYSA8PCAiXG4iOwogICAgfQp9OwoKY2xhc3MgQiA6IHB1YmxpYyBBCnsKcHVibGljOgogICAgdmlydHVhbCB2b2lkIGZ1bmMoaW50IGEgPSAyKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCAiY2xhc3MgQjo6IiA8PCBhIDw8ICJcbiI7CiAgICB9Cn07Cgp2b2lkIGZ1bmMoQSYgYSkgeyBhLmZ1bmMoKTsgfQoKaW50IG1haW4oKQp7CiAgICBCIGI7CiAgICBmdW5jKGIpOwogICAgYi5mdW5jKCk7CgogICAgcmV0dXJuIDA7Cn0K