In a situation when some struct D
inherits another struct A
twice: once privately via B
and the second time publicly via C
, is it allowed to write using B::A
in D
?
struct A {};
class B : A {};
struct C : A {};
struct D : B, C {
using B::A; //ok in GCC, error in Clang
};
The program is accepted by GCC, but Clang prints the error:
error: 'A' is a private member of 'A'
Demo: https://gcc.godbolt.org/z/5jeqrzorE
using B::A
must just expose injected class name A
from D
. On the one hand, A
is already available to use in D
(so GCC accepts it), but on the other hand A
is private within B
(so Clang rejects it). Which one compiler is right here?
class B
withstruct B
in your code. This changes the inheritance type from private to public. – Guanase