I have a class employee in which I have a static function with count number employee and and count to type of employee(e.g teacher ,assistant teacher,personal assistant etc) .For this purpose I have static class inside with I have a static count for number of employee and inside each subclass I want to access base class static method.
class Employee{
private static int emp;
//...code
static void IncreaseEmployeeCount()
{
emp=emp+1;
}
}
class Teacher : Employee{
private static int tchr;
//...code
static void IncreaseTeacherCount()
{
tchr = tchr + 1;
}
}
How can I access base class static method using child class. It tried using following but fails with compile time error:
Teacher teacher = new Teacher();
teacher.IncreaseEmployeeCount();
'Employee.IncreaseEmployeeCount()' is inaccessible due to its protection level
Adding public
access level still gives an error:
Member 'Employee.IncreaseEmployeeCount()' cannot be accessed with an instance reference; qualify it with a type name instead