-1

Inconsistent accessibility: Base class is less accessible than parent class. The error is coming on the base classes Circle and Oval. I think there is no issue of the curly brackets. How can I resolve?

namespace CheckingPolymor
    {
        class Shape
        {
            int width;
            int height;
            string color;

            public virtual void Draw()
            {

            }

        }

            public class Circle: Shape
            {
                public override void Draw()
                {
                    base.Draw();
                }
            }

            public class Oval: Shape
            {
                public override void Draw()
                {
                    base.Draw();
                }

            }                          
    }
Ammad Hassan
  • 95
  • 1
  • 12

1 Answers1

1

You either

  • make Shape public, or
  • remove public from Circle and Oval

This error occurs because you are making access modifiers pointless. Without any access modifiers, Shape is internal, which is less accessible than its subclasses, which are public. By accessing a subclass, you can also access members declared in the superclass. This makes the internal Shape pointless.

Sweeper
  • 213,210
  • 22
  • 193
  • 313