Вывести выровненные столбцы
Я изучаю C ++. У меня проблема с форматированием вывода моей программы. Я хотел бы напечатать там идеально выровненные столбцы, но пока я не могу это сделать, вот мой код:
int main()
{
employee employees[5];
employees[0].setEmployee("Stone", 35.75, 053);
employees[1].setEmployee("Rubble", 12, 163);
employees[2].setEmployee("Flintstone", 15.75, 97);
employees[3].setEmployee("Pebble", 10.25, 104);
employees[4].setEmployee("Rockwall", 22.75, 15);
printEmployees(employees, 5);
return 0;
}
// print the employees in my array
void printEmployees(employee employees[], int number)
{
int i;
for (i=0; i<number; i++) {
employees[i].printEmployee();// this is the method that give me problems
}
cout << "\n";
}
в классе сотрудник у меня есть метод print employee:
void printEmployee() const
{
cout << fixed;
cout << surname << setw(10) << empNumber << "\t" << setw(4) << hourlyRate << "\n";
}
Проблема в том, что когда я печатаю строку "flinstones", число emp и скорость не совпадают. как то так происходит
Stone 43 35.750000 Rubble 163 12.000000 Flintstone 97 15.750000 Pebble 104 10.250000 Rockwall 15 22.750000
Кто-нибудь может мне помочь? (Я пытался добавить вкладки .. но это не помогло)