I am learning to program in C ++. In the last class we saw something that the teacher called " Array with cap ". I wanted to deepen this concept in a self-taught way I looked for it but I could not find anything similar.
An example of the code we handle is:
#define N 20
#define TAM 100
typedef char palabra[N];
struct fecha { int dd; int mm; int aa; };
struct empleado { palabra nombre; palabra apellido; int cedula; fecha
nacimiento; };
fecha leo_fecha() { fecha f; cin >> f.dd >> f.mm >> f.aa; return f; }
empleado leo_empleado() {
empleado e;
cout << "Ingrese nombre: " << endl;
cin >> e.nombre;
cout << "Apellido: " << endl;
cin >> e.apellido;
cout << "Ingrese cedula: " << endl;
cin >> e.cedula;
cout << "Ingrese su fecha de nacimiento: ";
e.nacimiento=leo_fecha();
return e; }
struct arr_emp { empleado e [N]; int tope; };
arr_emp creo_vacioE() {
arr_emp a;
a.tope=0; }
bool es_vacioE(arr_emp a) {
return (a.tope==0); }
void agrego(arr_emp &a, empleado e) { a.e[a.tope]=e; }
void imprimoE(arr_emp a) {
for (int i=0; i<a.tope; i++)
imprimo_empleado(a.e[i]); }
int este_enE (arr_emp a, int cedula) {
for(int i=0; i<a.tope; i++)
{
if(a.e[1].cedula==cedula)
{
return i;
}
else
{
return -1;
}
} }
main () {
arr_emp a;
empleado e;
a=creo_vacioE();
if (es_vacioE(a)==0)
{
cout << "El arreglo esta vacio" << endl;
}
e=leo_empleado();
agrego(a,e);
}
I would be grateful if you could tell me what concept this refers to. Thanks.