#include <iostream>
struct base
{
virtual ~base() {}
virtual void foo() const { std::cout << "base::foo\n" ; }
void bar() const { std::cout << "base::bar\n" ; }
};
struct derived : base
{
virtual void foo() const override
{ std::cout << "derived::foo overrides base::foo\n" ; }
void bar() const
{ std::cout << "derived::bar hides base::bar\n" ; }
};
void fun( const base& b )
{
b.foo() ;
b.bar() ;
}
int main()
{
derived d ;
fun(d) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IGJhc2UKewogICAgdmlydHVhbCB+YmFzZSgpIHt9CiAgICB2aXJ0dWFsIHZvaWQgZm9vKCkgY29uc3QgeyBzdGQ6OmNvdXQgPDwgImJhc2U6OmZvb1xuIiA7IH0KICAgIHZvaWQgYmFyKCkgY29uc3QgeyBzdGQ6OmNvdXQgPDwgImJhc2U6OmJhclxuIiA7IH0KfTsKCnN0cnVjdCBkZXJpdmVkIDogYmFzZQp7CiAgICB2aXJ0dWFsIHZvaWQgZm9vKCkgY29uc3Qgb3ZlcnJpZGUKICAgIHsgc3RkOjpjb3V0IDw8ICJkZXJpdmVkOjpmb28gb3ZlcnJpZGVzIGJhc2U6OmZvb1xuIiA7IH0KCiAgICB2b2lkIGJhcigpIGNvbnN0CiAgICB7IHN0ZDo6Y291dCA8PCAiZGVyaXZlZDo6YmFyIGhpZGVzIGJhc2U6OmJhclxuIiA7IH0KfTsKCnZvaWQgZnVuKCBjb25zdCBiYXNlJiBiICkKewogICAgYi5mb28oKSA7CiAgICBiLmJhcigpIDsKfQoKaW50IG1haW4oKQp7CiAgICBkZXJpdmVkIGQgOwogICAgZnVuKGQpIDsKfQo=