I have a simple class here
class Leader : Inhabitants
{
public int ProducedWorth { get; set; }
public Leader(string name, int age, string profession, int producedWorth)
{
InhabitantID = InhabitantCount;
Name = name;
Age = age;
Profession = profession;
ProducedWorth = producedWorth;
}
public int GetProducedWorth()
{
return ProducedWorth;
}
}
which inherits from a Inhabitant class
class Inhabitants
{
static protected int InhabitantCount;
public Inhabitants()
{
InhabitantCount++;
}
public int InhabitantID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public string Profession { get; set; }
}
Now when I create new instances of the class it seems to work perfectly fine, but when I try to access to the producedWorth property that is only on the base class i get the error that the inherited class does not have said property?
var leadA = new Leader("Julien", 33, "Stone pit overseer", 6540)
//leadA.Name is accessible
//leadA.producedWorth is not accessible