Esempio n. 1
0
int main()
{
  Mammal *pDog = new Dog;
  pDog->move();
  pDog->speak();
  //pDog->tail();
  cout << "--------------\n";
  Mammal *super =  new Dog;
  super->speak();
  super->move();
  cin.get();
  return 0;
}
Esempio n. 2
0
int main()
{
    Mammal *pDog = new Dog;
    pDog->move();
    pDog->speak();
    return 0;
}
Esempio n. 3
0
int main()
{
	Mammal *pDog = new Dog;
	pDog->move(); // pDog is a Mammal pointer. The mammal method gets called.
	pDog->speak(); // ... but the Mammal.speak() method is virtual, so the Dog.speak() method is used instead.
	return 0;
}