, , , - , . , , .
( ). .
, . , , Point , Circle. , .
:
- ,
- ,
- .
private protected.
, , Circle,
Boolean Circle::IsInside(Point &P)
{
if ((X-P.GetX())*(X-P.GetX())+(Y-P.GetY())*(Y-P.GetY())<= R*R) return true;
else return false;
}
-. . -, GetX() GetY() P , - . X Y. X Y protected. , , IsInside() , , .
, , , .
, , (friend) . , friend.
friend , .
, .
Point Circle:
class Point
{
//...
friend Boolean IsInside (Circle &C, Point &P);
};
class Circle: public Point
{
//...
friend Boolean IsInside (Circle &C, Point &P);
};
,
friend Boolean IsInside (Circle &C, Point &P);
, (public, protected private).
:
Boolean IsInside(Circle &C, Point &P)
{
if ((C.X-P.X)*(C.X-P.X)+(C.Y-P.Y)*(C.Y-P.Y)<= C.R * C.R) return true;
else return false;
}
, IsInside(), ( , - ) Point Circle. . , , " ".
- .
class x
{
//...
void f();
};
class y
{
//...
friend void x::f();
};
, .
class y
{
//...
friend class x;
}
.
, _3d
class _3d
{
//...
_3d operator + (_3d b);
};
_3d _3d::operator + (_3d b)
{
_3d c;
c.x = x + b.x;
c.y = y + b.y;
c.z = z + b.z;
return c;
}
, + .
class _3d
{
//...
friend _3d operator + (_3d &a, _3d &b);
};
_3d operator + (_3d &a, _3d &b)
{
_3d c;
c.x = a.x + b.x;
c.y = a.y + b.y;
c.z = a.z + b.z;
return c;
}
, , . , , , , .
, : , , , .
. "=", "++" "+=" , , -, , . , , , , , . , "+", "", "||" .
,
class X {...};
X x;
x=1+x; // .. x = 1.operator + (x);
"+" . .
, , -, . , .
10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _. 10.11.2021 - 12:36: - Conscience -> . ? - _. 10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _. 10.11.2021 - 12:35: - Ecology -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> . - _. 10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _. 10.11.2021 - 09:18: - New Technologies -> , 5G- - _. 10.11.2021 - 09:18: - Ecology -> - _. 10.11.2021 - 09:16: - Ecology -> - _. 10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _. 10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _. |