G
Guest
Hi!
I'm just starting out in C# and I am wondering why the Cow objects gets a
"inaccessible due to protection level" in the following code:
namespace ClassesAndInheritance
{
class Program
{
static void Main(string[] args)
{
Cow myCow = new Cow();
myCow.EatFood();
Console.ReadKey();
}
}
class Animal
{
protected void EatFood()
{
Console.WriteLine("Mmmm... Yummy! I am an animal...");
}
protected void Breed()
{
Console.WriteLine("Hey! Here comes another!");
}
}
class Cow : Animal
{
protected void Moo()
{
Console.WriteLine("Moooo!");
}
protected void SupplyMilk()
{
Console.WriteLine("I am a cow... I give you milk...");
}
}
}
I'm just starting out in C# and I am wondering why the Cow objects gets a
"inaccessible due to protection level" in the following code:
namespace ClassesAndInheritance
{
class Program
{
static void Main(string[] args)
{
Cow myCow = new Cow();
myCow.EatFood();
Console.ReadKey();
}
}
class Animal
{
protected void EatFood()
{
Console.WriteLine("Mmmm... Yummy! I am an animal...");
}
protected void Breed()
{
Console.WriteLine("Hey! Here comes another!");
}
}
class Cow : Animal
{
protected void Moo()
{
Console.WriteLine("Moooo!");
}
protected void SupplyMilk()
{
Console.WriteLine("I am a cow... I give you milk...");
}
}
}