{filelink=13221}
#include "stdafx.h"
using namespace System;
class Animal
{
public:
virtual void Cri ()
{
Console::WriteLine();
}
};
class Chien : public Animal
{
public:
virtual void Cri ()
{
Console::WriteLine("Woo Woo Woo");
}
};
class Chiot : public Chien
{
public:
virtual void Cri () // création d'une méthode virtuelle
{ // le mot virtuel n'est pas obligatoire
Console::WriteLine("Yap Yap");
}
};
class Chat : public Animal
{
public:
virtual void Cri ()
{
Console::WriteLine("Mian Mian");
}
};
Int32 main(void)
{
Animal *a[] = new Animal*[4];
a[0] = new Chat();
a[1] = new Chien();
a[2] = new Chiot();
a[3] = new Animal();
for (Int32 i = 0; i Count; i++)
{
a[i]->Cri();
}
return 0;
}