when compiling some code that I encountered a compiler error, which seemed strange to me, and related to inheritance, nested classes, using declarations and access modifiers.
Basically, the intention is that the derived type can expose a nested protected class of the base type.
The following short example to demonstrate the problem:
class Base { protected: struct Nested { enum value_enum { val = 0, val2, val3 }; }; }; class Derived : public Base { public: using Base::Nested; }; int main(int argc, char** argv) {
Watch live .
MSVC11 (v11.00.61030) throttles this code with the following error:
error C2248: "Base :: Nested": cannot access the protected structure declared in the "Base" class
Both GCC and Clang compile this correctly, so without the ability to quote the relevant parts from the standard, I would say that this is an MSVC error.
Is there any way around this using MSVC?
source share