I have question with this same title here but now as I’ll present in code below this seems to behave in the opposite way to the way explained to me in my first question with the same title. Ok code:
class LINT_rep
{
private:
char* my_data_; //stores separately every single digit from a number
public:
class Iterator:public iterator<bidirectional_operator_tag,char>
{
private:
char* myData_
public:
Iterator(const LINT_rep&);
};
};
#include "StdAfx.h"
#include "LINT_rep.h"
LINT_rep::Iterator::Iterator(const LINT_rep& owner):myData_(nullptr)
{
myData_ = owner.my_data_; /*
HERE I'M ACCESSING my_data WHICH IS PRIVATE AND THIS
CODE COMPILES ON VS2010 ULTIMATE BUT IT SHOULDN'T
BECAUSE my_data IS PRIVATE AND OTHER CLASS SHOULDN'T
HAVE ACCESS TO IT'S PRIVATE MEMB. AS EXPLAINED TO ME IN
QUESTION TO WHICH I;VE PROVIDED LINK. */
}
Question in the code. Thanks.
Access rights for nested classes to members of the enclosing classes are changing in the upcoming C++0x standard. In the current standard, 11.8 says:
In the draft for C++0x, this changes to
Some compilers are adopting the new access rules; from your question, I guess VS2010 does, and I know from experience that GCC has done for some time.