== Why is this an issue?

While it is possible for inheritance to be non-``++public++``, it is rarely justified and complicates the use of the derived class. For instance, inherited member visibility is diminished and implicit and ``++static_cast++`` casts from the derived class to the base class will not work. 


It is sometimes used to limit the base class functionality available in the derived class. When that is the desire, composition should be used instead.


=== Noncompliant code example

[source,cpp]
----
class B : private A {  // Noncompliant
  // ...
}
----


=== Compliant solution

[source,cpp]
----
class B : public A {
  // ...
}
----
or

[source,cpp]
----
class B {
  private: 
  A a;
  // ...
}
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Make this inheritance "public".


=== Highlighting

visibility keyword and inherited class name


'''
== Comments And Links
(visible only on this page)

=== on 7 Jan 2016, 20:16:35 Alban Auzeill wrote:
In the bellow description there's nothing about {color:#8eb021}protected{color} inheritance. What I've done in rule's implementation, is applying the same logique to {color:#8eb021}private{color} and {color:#8eb021}protected{color}.

Do we have to change the documentation about this?


I also distinguish the default inheritance of a class as private and  the default inheritance of a struct as public.

My non-compliant test cases are:

----
class B : A {
};

class C : protected A {
};

struct D : protected A {
};

class E : private A {
};

struct F : private A {
};
----

My compliant test cases are:

----
struct B : A {
};

class C : public A {
};

struct D : public A {
};
----

Do you agree?

=== on 7 Jan 2016, 20:40:38 Ann Campbell wrote:
Since both the title and description are about "non-public" inheritance, I think the ``++protected++`` case is already adequately covered. Note that the Noncompliant Code Example only shows ``++private++`` inheritance because adding a ``++protected++`` example wouldn't have contributed anything significant.

endif::env-github,rspecator-view[]
