how to remove error: expected primary-expression before ‘.’ token [closed]

Employee is a type name and itself doesn’t have members to read data in.
Use the variable to access members.

Additionally, you may want to use a reference to modify caller’s local variable.
Add & after the type name to use reference.

void Setter(Employee& E)   //function for setting value in Employees 
{
    cout<<"Enter Id:";
    cin>>E.Id;
    cout<<"Enter Name:";
    cin>>E.Name;
    cout<<"Enter Gender:";
    cin>>E.Gender;
    cout<<"Enter Designation:";
    cin>>E.Des;
    cout<<"Enter Date of joining(DD/MM/YYYY):";
    //cin>>E.Date.day>>E.Date.month>>E.Date.year;
}

Note that the comment-outed line

cin>>E.Date.day>>E.Date.month>>E.Date.year;

is wrong because the type of E.Date is int and it won’t have members. You will have to alter the strucure’s declaration to let the structure hold a date (or three additional integers).

Leave a Comment