Original Post
Hi, I recently moved to C# because i liked the noob friendly syntax. But can some one please tell me why i get these errors: Error 3 'Animal.age' is inaccessible due to its protection level C:\Documents and Settings\Alex Mullins.ALEX-AE87B4CE0A\Desktop\DirectX\directx\ConsoleApplication1\Program.cs 35 85 ConsoleApplication1 Error 4 'Animal.weight' is inaccessible due to its protection level C:\Documents and Settings\Alex Mullins.ALEX-AE87B4CE0A\Desktop\DirectX\directx\ConsoleApplication1\Program.cs 35 90 ConsoleApplication1 here is the source code Thank you for any help
[source lang = c#]
using System;
public class Animal
{
//private member variables
private int age;
private int weight;
public Animal(int age, int weight)
{
this.age = age;
this.weight = weight;
}
public void ShowA()
{
Console.WriteLine("Animal is {0} and weighs {1}", age, weight);
}
}
public class Human : Animal
{
private string species = "Human";
private string name;
public Human(int age, int weight, string name) :
base(age, weight)
{
this.name = name;
}
public void ShowH()
{
Console.WriteLine("{0} is {1} years old and weighs {2} and is a {3}", name, age, weight, species);
}
}
public class Tester
{
public static void Main(string[] args)
{
Animal a = new Animal(1, 12);
a.ShowA();
Human h = new Human(14, 180, "alex");
h.ShowH();
}
}