, , , . .
:
class Parent {....};
class Child : [ ] Parent {....};
- (:), . -. , , - "" -. , "" private (), public () protected (), . , private , , public , . , protected. protected , , , . Protected private : .
, , , .
public | protected | private | ||
public | public | protected | private | |
protected | protected | protected | private | |
private |
, , .
, / .
, , . .. , , (--), : - - . : - - .
, " " , , , , , . , , .
class BaseClass
{
public:
BaseClass() {cout << ' \n';}
~BaseClass() {cout << ' \n';}
};
class DerivedClass: public BaseClass
{
public:
DerivedClass() {cout << ' \n';}
~DerivedClass() {cout << ' \n';}
};
main()
{
DerivedClass obj;
}
, . . , . , . , , . .
__ ( )
: __ ( )
{
... //
}
. , . , , , .. , , .
class BaseClass
{
int i;
public:
BaseClass (int ii) {i=ii;}
~BaseClass() {cout << ' \n';}
};
class DerivedClass: public BaseClass
{
int n;
public:
DerivedClass (int nn, int m): BaseClass (m) {n=nn;}
~DerivedClass() {cout << ' \n';}
};
main()
{
DerivedClass obj(2,3);
}
, , .
class BaseClass
{
int j, i;
public:
BaseClass (int jj, int ii) {j=jj; i=ii;}
~BaseClass() {cout << ' \n';}
};
class DerivedClass: public BaseClass
{
int n;
public:
DerivedClass (int nn);
~DerivedClass() {cout << ' \n';}
};
DerivedClass :: DerivedClass (int nn): BaseClass (nn/2, nn%2)
{ n=nn; }
main()
{
DerivedClass obj(15);
}
, (!!!) .
, . , .
struct Point
{
int X;
int Y;
};
, , "". :
enum Boolean {false, true}; // false = 0, true = 1
struct Point
{
int X;
int Y;
Boolean Visible;
};
Boolean . enum true () false (). 0, Boolean : 0 1 ( ).
_3d, Point. , "" . , , - , , . :
enum Boolean {false, true}; // false = 0, true = 1
class Point
{
protected:
int X;
int Y;
Boolean Visible;
public:
int GetX(void) { return X; }
int GetY(void) { return Y; }
Boolean isVisible (){ return Visible;}
Point (const Point& cp); //
Point (int newX =0, int new Y =0); //
};
Point :: Point (int NewX, int NewY) //
{
X = newX; Y = newY; Visible = false;
}
Point :: Point (const Point& cp) //
{
X = cp.X; Y = cp.Y; Visible = cp.Visible;
}
Point:
Point Center(320, 120); // Center Point
Point *point_ptr; // Point
point_ptr = &Center; // Center
:
Point aPoint ();
Point Row[80]; // Point
Point bPoint (100);
Point , . Point .
class Point
{
...
public:
...
void Show();
void Hide();
void MoveTo(int newX, int newY);
};
void Point::Show()
{
Visible = true;
putpixel (X,Y,getcolor());
}
void Point::Hide()
{
Visible = false;
putpixel (X,Y,getbkcolor());
}
void Point::MoveTo (int newX, int newY)
{
Hide ();
X = newX;
Y = newY;
Show ();
}
, Point, , , .
Point pointA (50,50);
pointA.Show ();
pointA.MoveTo (100,130);
pointA.Hide ();
, : " ", Point, . , , , Point , / .
Circle . , , . , ( X Y / ) . -, Circle , Radius, , Circle, , Point. Circle X, Y, Visible, Circle.
class Circle: public Point
{
int Radius; // private
public:
Circle (int initX, int initY, int initR);
void Show ();
void Hide ();
void Expand (int deltaR);
void Contract (int deltaR);
void MoveTo (int newX, int newY);
};
void Circle::Show ()
{
Visible = true;
circle (X,Y, Radius);
}
void Circle::Hide () // =
{
Visible = false;
unsigned int tempColor = getcolor ();
setcolor (getbkcolor());
circle (X,Y, Radius);
setcolor (tempColor);
}
void Circle::Expand (int deltaR)
{
Hide();
Radius += deltaR;
Show();
}
void Circle::Contract (int deltaR)
{
Expand (-deltaR);
}
void Circle::MoveTo (int newX, int newY)
{
Hide ();
X = newX;
Y = newY;
Show ();
}
main()
{
int graphDr = DETECT, graphMode;
initgraph ( &graphDr, &graphMode, "");
Circle C (150,200,50); // .(150, 200) 50
C.Show(); //
getch();
C.MoveTo (300,100); //
getch();
C.Expand (50); //
getch();
C.Contract (70); //
getch();
closegraph();
}
Circle Point, , , Circle Point X, Y, Visible, isVisible(), GetX(), GetY(). Show(), Hide() MoveTo() Circle, , , , , , .
, Circle Circle Point. Circle::Expand. Radius. . Radius private Circle. Radius Circle.
Circle::Hide Circle::Show. Visible Point. Visible protected Point. Circle public Point. , Visible protected Circle. , Visible private Point, Circle. Visible c public. Visible .
.
, . :
, . , , .
,
Point APoint, *ptrPoint;
Circle ACircle, *ptrCircle;
:
APoint = ACircle;
.
.
, :
1. ,
2. ,
. ,
, () , ,
.
. .
, , .
. , .
. ,
void Proc (Point param)
Point, Circle .
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 -> - _. |