- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
#include <iostream>
class A
{
public:
virtual void print(int val = 10) { std::cout << "A" << val; }
};
class B : public A
{
public:
virtual void print(int val = 20) { std::cout << "B" << val; }
};
int main()
{
B b;
A& a = b;
a.print();
return 0;
}