Inconsistent accessibility: base class is less accessible than class

Ivan Prodanov picture Ivan Prodanov · Nov 7, 2012 · Viewed 36.4k times · Source

So I have an abstract base class in a DLL and child classes of that class. I want the childs to be public, but the base to be private so that it cannot be accessed outside of the dll.

How do I do that?

Answer

Marc Gravell picture Marc Gravell · Nov 7, 2012

You don't and you can't.

If you want to expose the class as public, the base-type must be public. One other option is to have a public interface, and only expose the type via the interface (presumably with a factory method somewhere for creating instances).

One final option is to encapsulate the base-class rather than inherit it.