0I'm quite rusty at C++. I've tried various searches but can't come up with an answer. I have the following code:
class Base
{
  public:
    Base() {};
    virtual void hello() { std::cout << "I'm the base class" << std::endl; }
};
class Alice : public Base
{
  public:
    Alice() {};
    virtual void hello() { std::cout << "I'm Alice" << std::endl; }
};
class Bob : public Base
{
  public:
    Bob() {};
    virtual void hello() { std::cout << "I'm Bob" << std::endl; }
};
Base test(int alice)
{
  if(alice)
    return Alice();
  else
    return Bob();
}
int main()
{
  Base a = test(0);
  Base b = test(1);
  a.hello();
  b.hello();
}
I would expect the output to be
I'm Alice
I'm Bob
but instead it is
I'm the base class
I'm the base class
What (aside from Python-on-the-brain) is going on here?
 
    