给定对象“ a”已分配给对象“ b”的事实,为什么输出显示“ Base”?为什么不输出“派生”?
#include <iostream>
class A {
public:
virtual void display()
{
std::cout << "Base"; }
};
class B: public A
{
public:
void display()
{
std::cout << "Derived";
}
};
int main()
{
B b;
A a = b;
a.display();
return 0;
}