I have the following code
class A
{
private:
    class B
    {
    public:
        void f()
        {
            printf("Test");
        }
    };
public:
    B g() 
    {
        return B(); 
    }
};
int main()
{
    A a;
    A::B b; // Compilation error C2248
    A::B b1 = a.g(); //Compilation error C2248
    auto b2 = a.g(); // OK
    a.g(); // OK 
    b2.f(); // OK. Output is "Test"
}
As you can see I have class A and private nested class B. Without using auto I can't create instance of A::B outside A, but with auto I can. Can somebody explain what wrong here? I use VC++ 12.0, 13.0, 14.0 (always same behavior)
 
     
    