>>17
sorry, i forgot. but basically, "friend" allows functions outside the class access it's privates and protected stuff, that's why people bitch about it: example
class CSquare;
class CRectangle {
int width, height;
public:
int area (void)
{return (width * height);}
void convert (CSquare a);
};
class CSquare {
private:
int side;
public:
void set_side (int a)
{side=a;}
friend class CRectangle;
};
void CRectangle::convert (CSquare a) {
width = a.side;
height = a.side;
}
int main () {
CSquare sqr;
CRectangle rect;
sqr.set_side(4);
rect.convert(sqr);
cout << rect.area();
return 0;
}
here, CRectangle can access the "private int side" from CSquare because CRectangle was declared friend of CSquare.
That's the basic notion of "class friendship"