3GL   4GL   5GL   .

- ++

( )

, ++. (template). ?

, , , "" , , , . ?

, , . ++ , "".

, , (, ). - . ++, . , .

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

, . , . , . ( ) , .

++ .

, template, .

//
template <class X>
X min (X a, X b)
{
 return a<b ? a : b;
}

class , X .

.

...
//
int m = min (1, 2);
...

,

int min (int a, int b)
{
 return a<b ? a : b;
}

class . , <class T> , , . , , .

template <class T>
T toPower (T base, int exponent)
{
 T result = base;
 if (exponent==0) return (T)1;
 if (exponent<0) return (T)0;
 while (--exponent) result *= base;
 return result;
}

result , , 1 0, , .

, :

int i = toPower (10, 3);
long l = toPower (1000L, 4);
double d = toPower (1e5, 5);

int, long. , double. , :
int i = toPower (1000L, 4);

toPower() . "" , base result toPower(). toPower(), . , . , toPower() base result:

1. T result = base;
2. return (T)1;
3. return (T)0;
4. result *= base;
5. return result;

. toPower() - , , :

1 , ,
- 2 3 int , int, ,
- 4 *= , operator *=().
- 5 , T (. ).

:

class T
{
 public:
  T (const T &base); //
  T (int i); // int
  operator *= (T base);
  // ...
}

, , , , . , .

, , , . max():

template <class T>
T max (T a, T b)
{
 return a > b ? a : b;
}

max() , :

int i = max (1, 2);
double d = max (1.2, 3.4);

, , max() , , .

, :

int i = max ((int)'a', 100);

:

int max (int, int);
int j = max ('a', 100);

, .

template <class T1, class T2>
T1 max (T1 a, T2 b)
{
 return a > (T1)b ? a : (T1)b;
}

max() . ,
max ('a', 100);
( ) max()
char max (char, int);

. , , , . ,
max ('a', 100)
char,
max (100, 'a')
int.

, . (.. , ), . , , , ..

, . , . , , . , , .

template <class T>
class Pair
{
  T a, b;
 public:
  Pair (T t1, T t2);
  T Max();
  T Min ();
  int isEqual ();
};

, . , . , . , , Min() Pair:

template <class T>
T Pair <T>::Min()
{
 return a < b ? a : b;
}

, . Pair ( ) T , Min Pair :

T Pair::Min()
{
 return a < b ? a : b;
}

, -, template <class T>

. , Pair. () , Pair , Pair<int>, double Pair<double>, Vector Pair<Vector>. Pair<T>. , , .

Pair. , , Pair.

//
template <class T>
Pair <T>::Pair (T t1, T t2) : a(t1), b(t2)
{}

// Max template <class T>
T Pair <T>::Max()
{
return a>b ? a : b;
}

// isEqual template <class T>
int Pair <T>::isEqual()
{
if (a==b) return 1;
return 0;
}

, () , . . Pair , X,

X (X &); //
int operator == (X)
int operator < (X);

, , T Pair.

, ? , . . , .

:

, , . , . , , " 20 ", " 1000 " " 10 double".

, . Vector. Pair, Vector Min(), Max(), isEqual(). , . Pair . Vector :

template <class T, int n> class Vector
{
 public:
  Vector();
  ~Vector() {delete[] coord;}
  void newCoord (T x);
  T Max ();
  T Min();
  int isEqual();
 private:
  T *coord;
  int current;
};

n, , . Vector, n , :

//
template <class T, int n>
Vector <T, n>::Vector():
{
 coord = new T[n];
 current = 0;
}

// Max
template <class T, int n>
T Vector <T, n>::Max():
{
 T result (coord[0]); // *
 for (int i=0; i<n; i++)
  if (result < coord[i]) // **
 result = coord[i]; // ***
}

, . coord n , current 0.

, , . , ,

1. (*),
2. < (**), > Max(),
3. = (***).

- . , . , . , . , Vector double , Vector double.

, , . , . , , , , , , , , . , , .

, Vector, . , .

, , . , , . , , .

, , , Pair. Trio, a b Pair, c.

template <class T>
class Trio: public Pair <T>
{
 T c;
 public:
 Trio (T t1, T t2, T t3);
 ...
};

template <class T>
Trio<T>::Trio (T t1, T t2, T t3): Pair <T> (t1, t2), c(t3)
// ,
// .
{}

        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