It is considered that those definitions (members of classes, types etc) that are in the private part are data and types of the class itself. But there are exceptions that I don't understand. For example, why in the example below, do the C++ language rules fail to describe the type with the keyword auto?
class MyClassA
{
class MyClassB
{
public:
MyClassB::MyClassB() {};
MyClassB::~MyClassB() {};
void get() const {};
};
MyClassB m_B;
public:
MyClassA() {};
~MyClassA() {};
const MyClassB& get()
{
return m_B;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
MyClassA classA;
const MyClassA::MyClassB& ref1 = classA.get(); //! error C2248: 'MyClassA::MyClassB': cannot access private class declared in class 'MyClassA'
const auto ref2 = classA.get(); //! OK, but why is it good here?
ref1.get();
return 1;
}
What does the ะก++ standard say about this?
I am developing code using MSVS2015 (toolset v140)