虽然看过不少类似题,但我还是做错了!谁能详细为我讲解一下啊~
#include <iostream>
using namespace std;
class A
{
public:
virtual void Fun(int number = 10)
{
std::cout << "A::Fun with number " << number<<endl;
}
};
class B: public A
{
public:
virtual void Fun(int number = 20)
{
std::cout << "B::Fun with number " << number<<endl;
}
};
int main()
{
B b;
A &a = b;
a.Fun();
return 0;
}