3GL   4GL   5GL   .

- ++

, .

struct _3d
{
 double x, y, z;
 double mod () {return sqrt (x*x + y*y +z*z);}
 double projection (_3d r) {return (x*r.x + y*r.y + z*r.z) / mod();}
 _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; }

, . mod() protection() . : , - , "+".

, . - , , #include. , , , . , , ( inline ). . , inline .

( ), inline :

inline _3d _3d::operator + (_3d b)
{
 _3d c;
 c.x = x + b.x;
 c.y = y + b.y;
 c.z = z + b.z;
 return c;
}

"+" .

, , . -, inline . -, ++ , .

, inline , . - (, , switch goto) , .

. _3d struct{}, , , . , , , , , :

_3d vectorA;
double m;
vectorA.x = 17.56;
vectorA.y = 35.12;
vectorA.z = 1.0;
m = vectorA.mod();

, , , , , . _3d :

class _3d
{
 double x, y, z;
public:
 double mod () {return sqrt (x*x + y*y +z*z);}
 double projection (_3d r) {return (x*r.x + y*r.y + z*r.z) / mod();}
 _3d operator + (_3d b);
};

" " . . , , .

:

class _3d
{

 double x, y, z;
public:
 double mod () {return sqrt (x*x + y*y +z*z);}
 double projection (_3d r) {return (x*r.x + y*r.y + z*r.z) / mod();}
 void set (double newX, double newY, double newZ)
 {
  x = newX; y = newY; z = newZ;
 }
 _3d operator + (_3d b);
};

set() ( !).

: x, y z , , (. projection(...) "+"), - .

, , , , . ++ , . . , , , . , , .

++ , . , . , . , . , void.

, , . . , , . , . .

++ : "~_". , , . .

class _3d
{
 double x, y, z;
public:
 _3d();
 ~_3d()
 {
  cout << ' _3d \n';
 }
 double mod () {return sqrt (x*x + y*y +z*z);}
 double projection (_3d r) {return (x*r.x + y*r.y + z*r.z) / mod();}
 void set (double newX, double newY, double newZ)
 {
  x = newX; y = newY; z = newZ;
 }
 };

_3d::_3d() // _3d
{

 x=y=z=0;
 cout << ' _3d \n';
}

main()
{
 _3d A; // A
  // A.x = A.y = A.z = 0;
 A.set (3,4,0); // A.x = 3.0, A.y = 4.0, A.z = 0.0
cout << A.mod()<<'\n';
}

:

_3d
5.0
_3d

. . , , .

class _3d
{
 double x, y, z;
public:
 _3d ();
 _3d (double initX, double initY, double initZ);
 ...
};

_3d::_3d(double initX, double initY, double initZ)
// _3d
{
 x = initX;
 y = initY;
 z = initZ;
 cout << ' _3d \n';
}

main()
{
 _3d A; // A
 // A.x = A.y = A.z = 0;
 A.set (3,4,0); // A.x = 3.0, A.y = 4.0, A.z = 0.0
 _3d B (3,4,0); // B
 // B.x = 3.0, B.y = 4.0, B.z = 0.0
}


_3d B = _3d (3,4,0);

, . , .

B A, . . , .

, . , , , . , .

, .. . , , , - ( ).

, , . .

, . , A B, A B. , . , , . , .

class ClassName1
{
 int a, b;
public:
 void set (int ia, int ib) {a=ia; b=ib;}
};

class ClassName2
{
 int a, b;
public:
 void set (int ia, int ib) {a=ia; b=ib;}
};

ClassName1 c1;
ClassName2 c2;
c2 = c1;

.

, , . , . ,

class Pair
{
 int a, *b;
public:
 void set (int ia, int ib) {a=ia; *b=ib;}
 int getb (){return *b;}
 int geta (){return a;}
};

main()
{
 Pair c1,c2;
 c1.set(10,11);
 c2 = c1;
 c1.set(100,111);
 cout << '2.b = '<< c2.getb();
}

"c2.b = 111", 11, .

, , (.. ) .

class Pair
{
 int a, *b;
public:
 Pair operator = (Pair p)
 {
  a = p.a;
  *b = *(p.b);
  return *this;
 }
 ...
};

.

class _3d
{
 double x, y, z;
public:
 _3d ();
 _3d (double initX, double initY, double initZ);
 double mod () {return sqrt (x*x + y*y +z*z);}
 double projection (_3d r) {return (x*r.x + y*r.y + z*r.z) / mod();}
 _3d operator + (_3d b);
 _3d operator = (_3d b);
};

_3d _3d::operator = (_3d b)
{
x = b.x;
y = b.y;
z = b.z;
return *this;
}

, _3d , "+" "=". - , . this. , , , this. , .

- , - . "=" , (a=b=c). - this. , , - this.

, . , _3d, projection(...), operator +(...) operator = (...) _3d.

, ++ , . , , , , . , .

. , , , . . , ? , , , , ( , ) . , , , , , , , . , , , , , "", .

class ClassName
{
public:
 ClassName ()
 {
  cout << ' \n';
 }
 ~ClassName ()
 {
  cout << ' \n';
 }
};

void f (ClassName o)
{
 cout << ' f \n';
}

main()
{
 ClassName c1;
 f (c1);
}


f

. 1. : o, c1. , , , , , .

.

, : -, , , -, return. , , "" .

class ClassName {
public:
 ClassName ()
 {
  cout << ' \n';
 }
 ~ClassName ()
 {
  cout << ' \n';
 }
};

ClassName f()
{
 ClassName obj;
 cout << ' f \n';
 return obj;
}

main()
{
 ClassName c1;
 c1 = f();
}



f


: 1 obj. . ? , 1, - obj. "" ( ) , . , . , , . , , , , .

, . .

:

_ (const _ & obj)
{
 ... //
}

obj . ( .) , . . -, . -, , . , , .

class ClassName
{
public:
 ClassName ()
 {
  cout << ' \n';
 }
 ClassName (const ClassName& obj)
 {
  cout << ' \n';
 }
 ~ClassName ()
 {
  cout << ' \n';
 }
};

main()
{
 ClassName c1; //
 ClassName c2 = c1; //
}

: .

, , . , , .

, , . , .

, ".". , . . "->".

, .

, &.

main()
{
 _3d A (2,3,4);
 _3d *pA;
 pA = &A;
 double dM = pA->mod();
}

++ , . , .

. , , , .

void ToZero (_3d *vec)

{
 vec->set (0,0,0); // " -> "
}

main()
{
 _3d A (2,3,4);
 ToZero (&A);
}

++ , , .

void ToZero (_3d &vec)
{
 vec.set (0,0,0); // " . "
}

main()
{
 _3d A (2,3,4);
 ToZero (A);
}

, , . , "*". , .

, - , , , , .

. -, , . -, , .

. this. , . "=", "=" . , , .

_3d& _3d::operator = (_3d& b)

{
 x = b.x;
 y = b.y;
 z = b.z;
 return *this;
}

, , "=", .

        3GL   4GL   5GL   .

, - - . .




 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 -> - _.
Bourabai Research -  XXI Bourabai Research Institution