inheritance error is::Error 1 Inconsistent accessibility: base class 'person' is less accessible than class 'employee'

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//person class
 public  class person
{
  public  string name;
  public double CNIC_no;
    public void Information()
    {
        Console.WriteLine("Enter your name");
        name = Console.ReadLine();
        Console.WriteLine("Enter your id");
        CNIC_no =double.Parse( Console.ReadLine());   
    }
    public void print()
    {
     Console.WriteLine( "your name is {0}",name);
      Console.WriteLine(" your CNIC_no is {0}",CNIC_no);

    }
}
//student class and inherit to person
class student: person
{
    string class_name;
    int id;
    public void Information_student()
    {
        Console.WriteLine("Enter your class name");
        class_name = Console.ReadLine();
        Console.WriteLine("Enter your id");
       id = int.Parse(Console.ReadLine());
    }
    public void print1()
    {
     Console.WriteLine( "your class name is {0}",class_name);
      Console.WriteLine(" your id_no is {0}",id);

    }

}
public class employee: person
{
    string post;
     int salary;
    public void Information_employee()
    {
        Console.WriteLine("Enter your post");
        post = Console.ReadLine();
        Console.WriteLine("Enter your salary");
       salary = int.Parse(Console.ReadLine());
    }
    public void print2()
    {
     Console.WriteLine( "your post is {0}",post);
      Console.WriteLine(" your salary is {0}",salary);

    }

}
    class Program
    {
        static void Main()
        {
     employee s11=new employee();
            Console.Write("person information");
           s11.Information();
            s11.print();
            //Console.Write("student information");
            //s11.Information_student();
            //s11.print1();
            Console.Write("emplyee information");
            s11.Information_employee();
            s11.print2();
            Console.ReadKey();

        }
    }

Recommended Answers

All 2 Replies

s11 is an employee and also a person. It is not a student!
s11 is not a meaningful name, try to give more meaningful names to your variables.
If you would have named s11 as AnEployee or something, you would have noticed that AnEployee.Informatio_student(); does not work. You first have to create a new student class.
Hope this helps.

inheritance error is::Error 1 Inconsistent accessibility: base class 'person' is less accessible than class 'employee'

On line 25 declare your class public. It is missing so it's default accessor is private.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.