Internal class and access to external members.

Posted by Knowing me knowing you on Stack Overflow See other posts from Stack Overflow or by Knowing me knowing you
Published on 2010-05-21T10:34:21Z Indexed on 2010/05/21 10:50 UTC
Read the original article Hit count: 221

Filed under:
|

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*>
    {
        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.

© Stack Overflow or respective owner

Related posts about c++

Related posts about iterator