0

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();

        }
    }

Edited by pritaeas: Moved.

3
Contributors
2
Replies
13
Views
1 Year
Discussion Span
Last Post by pritaeas
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.