Error data structure "[error] request for member 'nom' in 'emp1? which is of non class type employer [3]

1

I'm doing a code in which I use data structure to enter the data of three different users (name identification and salary) but when I tried the code only with one user I get the error that I put in the title What do I do?

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>

using namespace std;
struct Empleado {
    string Nom;
    int ced;
    float sueldo;
};
string emp1;

int main (){
    char op;

        do{

        cout<<"bienvenido."<<endl;
        cout<<"Digite la opcion a la que desea acceder:"<<endl;
        cout<<endl;
        cout<<"1. ingresar usuarios."<<endl;
        cout<<"2. Modificar usuarios."<<endl;
        cout<<"3. Eliminar usuarios."<<endl;
        cout<<"4. Salir."<<endl;
        cin>>op;

        switch(op)
        {
            case '1':{
                cout<<"ingresar usuarios."<<endl;
                    Empleado emp1[3];
    cout<<"ingrese nombre empleado 1:"<<endl;
    cin>>emp1.Nom;
    cout<<"ingrese cedula empleado 1:"<<endl;
    cin>>emp1.ced;
    cout<<"ingrese sueldo usuario 1:"<<endl;
    cin>>emp1.sueldo;

                break;
            }
        }




    system("pause");
    }while  (op!='4');



}
    
asked by Yelkin Adrian Rubiano Romero 02.09.2017 в 17:09
source

1 answer

0
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>

using namespace std;
struct Empleado {
string Nom;
int ced;
float sueldo;
};
string emp1;

int main (){
char op;
Empleado Empleados[3]; //Array de 3 empleados.
int i = 0;
    do{

    cout<<"bienvenido."<<endl;
    cout<<"Digite la opcion a la que desea acceder:"<<endl;
    cout<<endl;
    cout<<"1. ingresar usuarios."<<endl;
    cout<<"2. Modificar usuarios."<<endl;
    cout<<"3. Eliminar usuarios."<<endl;
    cout<<"4. Salir."<<endl;
    cin>>op;

    switch(op)
    {
        case '1':{
            cout<<"ingresar usuarios."<<endl;
cout<<"ingrese nombre empleado 1:"<<endl;
cin>>Empleados[i].Nom;
cout<<"ingrese cedula empleado 1:"<<endl;
cin>>Empleados[i].ced;
cout<<"ingrese sueldo usuario 1:"<<endl;
cin>>Empleados[i].sueldo;
i++;
            break;
        }
    }




system("pause");
}while  (op!='4');



}

Hi, I do not know if you were looking for that. An array of employees which you fill.

    
answered by 02.09.2017 в 17:31