Originally Posted by
wysota
It means oobjects of the Outer::Inner1 class can access private members of Outer class instances.
Sorry, I don't understand how expolit this two lines; see this ,please:
class Shape {
class Type;
friend class Shape::Type;
int _number;
double _x, _y;
class Type {
Shape* _parent;
public:
Type(Shape* sh) : _parent(sh) {
double d = _parent->compute();
double d2 = _x; //is this an access ? It works only with "parent->_x"
}
};
Type _type;
public:
Shape(double x = 0, double y = 0) : _type(this), _x(x), _y(y) { }
double compute() { return _x * _y; }
};
class Shape {
class Type;
friend class Shape::Type;
int _number;
double _x, _y;
class Type {
Shape* _parent;
public:
Type(Shape* sh) : _parent(sh) {
double d = _parent->compute();
double d2 = _x; //is this an access ? It works only with "parent->_x"
}
};
Type _type;
public:
Shape(double x = 0, double y = 0) : _type(this), _x(x), _y(y) { }
double compute() { return _x * _y; }
};
To copy to clipboard, switch view to plain text mode
Where can I access to provate member of Shape ? (and how?)
Bookmarks