class Animal
{
public virtual void MakeSound()
{
Console.WriteLine("The animal makes a sound");
}
}
class Dog : Animal
{
public override void MakeSound()
{
Console.WriteLine("The dog barks");
}
}
class Cat : Animal
{
public override void MakeSound()
{
Console.WriteLine("The cat meows");
}
}
// Usage
Animal myAnimal = new Animal();
Animal myDog = new Dog();
Animal myCat = new Cat();
myAnimal.MakeSound(); // Output: The animal makes a sound
myDog.MakeSound(); // Output: The dog barks
myCat.MakeSound(); // Output: The cat meows