In the following code you can see that I'm inheriting the base class ctors into the derived class under the "private" access specifier. My initial thought would be that these would adapt to the access specifiers that I have given (here "private") and hence not be available to use, but I seem to be mistaken. What are the rules for inheriting base class constructors and operators regarding access specifiers in the derived class?
#include <cstdio>
class base
{
public:
base(int i) {
printf("Public base class ctor called!");
}
private:
base(bool b) {
printf("Private base class ctor called!");
}
};
class derived final : public base
{
private:
using base::base;
};
int main()
{
derived d(2);
// issues "is private within this context"
// derived e(true);
}
Outputs:
Public base class ctor called!
(expected derived ctor to be "private" in this context)