Esempio n. 1
0
int main()
{
  const Cat c;
  c.MakeSound();

  const Dog d;
  d.MakeSound();
}
Esempio n. 2
0
int main()
{
  const Cat c;
  c.MakeSound();

  const Dog d;
  d.MakeSound();

  //Now use the same Animal pointer for different animals
  Animal * animal{new Cat};
  animal->MakeSound();
  delete animal;
  animal = new Dog;
  animal->MakeSound();
  delete animal;
}