0

for loop to read details for employees

Should company name be XYZ & in the for loop body i want to enter staffNo/DeptID/AnnualSalary. What does this code mean: cin >> XYZ[i].staffNo;

12th May 2018, 1:28 AM
johnson
johnson - avatar
2 odpowiedzi
+ 3
Without the entire code, it lacks context for telling what the snippet signifies. However, XYZ is supposed to be an array of class or struct objects (supposingly class/struct staff) which at least has the structure of: struct staff { int staffNo; }; The original declaration of the array of class/struct object would be: staff* XYZ = new staff[n]; where n is the number of staff objects. The member of each object can then be initialized with user input via the statement cin >> XYZ[i].staffNo; inside a for loop.
12th May 2018, 1:55 AM
Hatsy Rei
Hatsy Rei - avatar
0
For(int i=0; i < 5;i++) { cout << “Enter staff no of the employee “<< endl; cin >> XYZ[i].staffNo; } I need to understand what this line means in context or any link that may refer me to more practice in this. cin >> XYZ[i].staffNo
12th May 2018, 7:10 PM
johnson
johnson - avatar